Easy · Strings

Find first unique character

Given a string s of lowercase letters, return the index of the first character that appears exactly once in s, or −1 if every character repeats.

Examples

Example 1

{
  "s": "notebook"
}

Output: index 0

Example 2

{
  "s": "aabb"
}

Output: -1 (no unique char)

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Strings problems