#C11103. First Non-Repeating Character

    ID: 40383 Type: Default 1000ms 256MiB

First Non-Repeating Character

First Non-Repeating Character

The task is to find the first non-repeating character from a given string. The string will consist solely of lowercase alphabets. If every character in the string repeats, you must output -1.

Formally, if the given string is denoted by \( s \), you need to find the smallest index \( i \) such that the character \( s[i] \) appears exactly once in \( s \). If no such index exists, output \(-1\).

Examples:

  • s = 'swiss' returns 'w'
  • s = 'racecar' returns 'e'
  • s = 'xxxyyy' returns -1

inputFormat

The input is provided via standard input (stdin) and consists of a single line containing a string \( s \) made up of lowercase alphabets. The string may be empty.

outputFormat

Output the first non-repeating character. If no such character exists, output -1. The output should be written to standard output (stdout).

## sample
swiss
w