All tasks
Mediumstringshash

First Non-Repeating Character

Time limit 2 s · Memory 64 MBAcceptance: —Solved by: 0

Statement

You are given a string of lowercase Latin letters. Print the first character that occurs in the string exactly once. If there is no such character, print -1.

Examples

Example 1
Input
aabcc
Output
b
Example 2
Input
aabb
Output
-1

Constraints

  • String length is between 1 and 10^5
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.