#K48312. First Unique Character in a String

    ID: 28393 Type: Default 1000ms 256MiB

First Unique Character in a String

First Unique Character in a String

Given a string s, find the index of the first non-repeating character in s. If no such character exists, return -1.

More formally, let \( s = s_0 s_1 \dots s_{n-1} \) be a string. You need to find the smallest index \( i \) such that the frequency of \( s_i \) in \( s \) is 1. If no such index exists, output -1.

For example, for the input "loveleetcode", the first non-repeating character is 'v' at index 2.

inputFormat

The input consists of a single line containing the string s. The string may contain letters and other printable characters.

Input is provided via standard input (stdin).

outputFormat

Output a single integer — the index of the first non-repeating character. If no such character exists, output -1.

Output should be written to standard output (stdout).

## sample
loveleetcode
2