JPMorgan ChaseOA #27
First Unique Character (Data & Analytics)
估计简单可在线判题
考点(AI 标注)哈希计数
Return the index of the first character in a lowercase string that appears exactly once in the whole string, using 1-based indexing; return −1 if there is none.
输入格式
The first line contains n, and the second line contains the string; 1≤n≤100000, lowercase English letters only.
输出格式
Output a single integer answer.
样例 1
输入:
10
statistics
输出:
3
样例 2
输入:
11
hackthegame
输出:
3
样例 3
输入:
4
aabb
输出:
-1
样例说明
The outputs of the three public examples are, in order: 3; 3; -1. These answers have been checked by independent enumeration or direct simulation.