cswork / OAOpen practice workspace

AmazonOA #148

Find First Unique

Estimated EasyJudge-ready

Topics (AI-labelled)HashingStrings

Return the position of the earliest character among those that occur only once in the whole string, explicitly using 1-based positions; if there is none, output −1.

Input

One line with a lowercase string of length 1..100000.

Output

Output a single integer answer.

Example 1

Input:

statistics

Output:

3

Example 2

Input:

aabb

Output:

-1

Example 3

Input:

zabz

Output:

2

Example notes

Example 1: a is the earliest and occurs only once, at position 3. Example 2: both a and b repeat, so there is no unique character; output −1. Example 3: a is unique at position 2 and earlier than b, so output 2.

Editorial

Loading solution…