Explore
ProGrad Programs
About Us

Edit
Reply




Edit

Find the first non-repeating character in a string | FACE Prep

Published on 11 Mar 2020

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.


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


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


C
C++
Java
Python 3

Output
Enter the string : focusacademy
First non-repeating character is f


Recommended Programs






If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in
Explore 'c'
Articles