#K72657. First Non-Repeating Character

    ID: 33802 Type: Default 1000ms 256MiB

First Non-Repeating Character

First Non-Repeating Character

In this problem, you are given a string (s) consisting of only lowercase English alphabets. Your task is to find and return the index of the first character that does not repeat itself in the string. If there is no such character, output (-1).

For example, if (s = \texttt{leetcode}), then the answer is 0 because the character 'l' appears only once. Similarly, for (s = \texttt{loveleetcode}), the first non-repeating character is 'v' at index 2.

inputFormat

The input consists of a single line containing a string (s) made up of lowercase English letters.

outputFormat

Output a single integer that represents the index of the first non-repeating character in the string. If every character repeats, output (-1).## sample

leetcode
0