#K4516. Find the First Unique Character in a String

    ID: 27692 Type: Default 1000ms 256MiB

Find the First Unique Character in a String

Find the First Unique Character in a String

Given a string \( s \), your task is to find the index of the first character that does not repeat anywhere in the string. If no such character exists, output \( -1 \). The string may contain letters, digits, and other printable characters.

For example, in the string "leetcode", the first non-repeating character is 'l' at index 0. In "loveleetcode", the first non-repeating character is 'v' at index 2. In "aabb", all characters repeat so the output is -1.

inputFormat

The input consists of a single line containing the string \( s \). The string can be empty or up to a reasonable length.

outputFormat

Output a single integer representing the index of the first non-repeating character in \( s \). If there is no such character, output \( -1 \).

## sample
leetcode
0