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

Open every published interview problem, solution, scene, and memory room free, with no account.

More Strings problems