#K54902. First Unique Character
First Unique Character
First Unique Character
Given a string S, find and output the first character that appears exactly once in the string. A unique character is defined as a character that appears only once in S. If no such character exists, output an empty string.
Note: Your program should read the input from stdin
and write the output to stdout
.
For example, if the input is "hello", the output should be "h" because 'h' is the first character that does not repeat.
The solution involves counting the frequency of each character and then iterating through the string to find the first with a count of 1. In mathematical form, if we define the frequency function as \( f(c) \) for a character \( c \), then the answer is the first \( c \) in S such that \( f(c)=1 \). If no such \( c \) exists, output an empty string.
inputFormat
The input consists of a single line containing the string S. The string can include letters, digits, or other symbols.
outputFormat
Output a single line containing the first unique character found in the input string. If there is no unique character, output an empty string.
## samplehello
h