#C13007. First Non-Repeated Character
First Non-Repeated Character
First Non-Repeated Character
You are given a string s. Your task is to find the first character in s that does not repeat anywhere else in the string. If every character is repeated or the string is empty, output None.
For example, if s = "swiss", then the first non-repeated character is w
, because although s
appears more than once, w
appears only once and comes before any other unique characters.
Formally, consider a string s of length n. Let \( f(c) \) be the frequency of character \( c \) in s. You need to find the smallest index \( i \) (0-indexed) such that \( f(s_i) = 1 \). If no such index exists, output None.
inputFormat
The input consists of a single line containing the string s. The string may contain spaces and other printable ASCII characters.
outputFormat
Output a single line with the first non-repeated character in s. If there is no non-repeated character, output None (without quotes).
## sampleswiss
w