#C12359. First Non-Repeating Character
First Non-Repeating Character
First Non-Repeating Character
The task is to implement a function that finds the first non-repeating character in a given string. If every character in the string repeats or if the string is empty, your program should output an appropriate message.
Requirements:
- If the input string is empty, output
Empty string
. - If every character repeats, output
No non-repeating character found
. - Otherwise, output the first character that does not repeat.
This problem tests your ability to efficiently process strings and use hash tables (or dictionaries) to count occurrences. The expected time complexity is O(n) where n is the length of the string.
Hint: Use a single pass to count character frequencies and a second pass to identify the first character with a count of one.
inputFormat
The input consists of a single line consisting of a string s.
You should read this from standard input.
outputFormat
The output is a single line containing the first non-repeating character. If the string is empty, output Empty string
. If no non-repeating character exists, output No non-repeating character found
.
swiss
w