cswork / OA打开练习工作台

AmazonOA #148

Find First Unique

估计简单可在线判题

考点(AI 标注)哈希计数字符串

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.

输入格式

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

输出格式

Output a single integer answer.

样例 1

输入:

statistics

输出:

3

样例 2

输入:

aabb

输出:

-1

样例 3

输入:

zabz

输出:

2

样例说明

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.