#C14509. Find the First Unique Character
Find the First Unique Character
Find the First Unique Character
Given a string s
, your task is to find the first character that does not repeat in the string. If all characters repeat or if the string is empty, output None
.
For example, consider the string swiss
. The first non-repeating character is w
because although s
appears multiple times, w
appears exactly once.
The solution should be efficient and read input from standard input (stdin) and produce output to standard output (stdout).
Formally, let the string be s and define the frequency function as:
\( f(c) = \text{number of occurrences of } c \text{ in } s \)
Find the smallest index \( i \) such that \( f(s_i) = 1 \), and output \( s_i \). If no such index exists, output None
.
inputFormat
The input consists of a single line containing the string s
.
Note that s
can contain any characters and its length could be zero.
outputFormat
Output the first non-repeating character of the string. If there is no such character, output None
.
swiss
w