#C11622. First Non-Repeating Character
First Non-Repeating Character
First Non-Repeating Character
Given a string S, find the first character that does not repeat. If all characters repeat, output an underscore _
.
For example, in the string swiss
, the first non-repeating character is w
.
The solution requires reading multiple test cases from standard input and processing each string independently.
Note: If there is no character that appears only once, output _
.
inputFormat
The first line of input contains an integer T representing the number of test cases. Each of the following T lines contains a string S.
Input is read from standard input (stdin).
outputFormat
For each test case, print a single line with the first non-repeating character of the string S. If no such character exists, print an underscore _
.
Output is written to standard output (stdout).
## sample3
swiss
hello
aabbcc
w
h
_
</p>