#K37937. First Non-Repeating Character
First Non-Repeating Character
First Non-Repeating Character
Given a string s, your task is to find the first character that does not repeat in the string. If every character repeats, output an underscore (_
).
For example, for the string swiss
, the first non-repeating character is w
, while for aabbcc
no character appears exactly once, so the output should be _
.
The solution should be implemented such that it reads input from stdin and writes the result to stdout.
Note: Use the following LaTeX formatted explanation for counting the occurrences of characters:
$$\text{count}(c)=\text{number of times character } c \text{ appears in } s.$$
inputFormat
The input consists of a single line containing the string s (which can include letters, digits, symbols, etc.).
The string is read from stdin.
outputFormat
Output a single character which is the first non-repeating character in the string. If there is no such character, output an underscore (_
).
The result is printed to stdout.
## sampleswiss
w