#K44147. First Non-Repeating Character Index
First Non-Repeating Character Index
First Non-Repeating Character Index
Given a string s consisting of lowercase English letters, find the index of the first non-repeating character in the string. If no such character exists, output \( -1 \).
You are expected to count the frequency of each character and then identify the first character that appears only once. For instance, if \( s = \texttt{leetcode} \), then the correct answer is \( 0 \) because the character l
is the first character that does not repeat.
inputFormat
The input consists of a single line containing the string \( s \) (only lowercase alphabets) read from standard input.
outputFormat
Output a single integer which is the index of the first non-repeating character in the string. If every character repeats, output \( -1 \).
## samplea
0