Find the first non-repeating character in a string | faceprep

Find the first non-repeating character in a string | faceprep

Program to find the first non-repeating character in a string is discussed here. Given a string, the task is to find the first non-repeating character in the string.

Find the first non-repeating character in a string

Input and Output format:

The first line of the input consists of a string.


Sample Input 1:

teeterson

Sample Output 1:

r

Sample Input 2:

charactercharacter

Sample Output 2:

All characters are repetitive


face prep pro ad banner

Click here to learn more about FACE Prep PRO


Algorithm to find the first non-repeating character in a string

  • Input the string from the user.
  • Start traversing the string using two loops.
  • Use the first loop to scan the characters of the string one by one.
  • Use the second loop to find if the current character is occurring in the latter part if the string or not.
  • If it is not occurring, print that character.
  • Else, continue traversing.

Program to find the first non-repeating character in a string

@@coding::1@@


face prep pro ad banner

Click here to learn more about FACE Prep PRO



Recommended Programs


Find the first non-repeating character in a string

c