#K94157. First Non-Repeated Character
First Non-Repeated Character
First Non-Repeated Character
Given a string s
, you are required to find its first non-repeated character. In other words, find the first character that occurs exactly once in s
. If there is no such character or the string is empty, return an empty string.
The solution should be implemented using standard input and output. Specifically, your program should read the entire string from standard input (stdin
) and print the answer to standard output (stdout
).
Note: The problem involves processing the input string to count the frequency of each character and then finding the first character with a frequency of one. In mathematical terms, if we denote the frequency function as \(f(c)\), then the task is to find the smallest index \(i\) such that \(f(s_i) = 1\), if it exists.
inputFormat
The input consists of a single line containing a string s
(possibly empty). The string is read from standard input.
outputFormat
Output the first non-repeated character in s
. If there is no non-repeated character, output an empty string. The output should be printed to standard output.
abacabad
c