Skip to content

Hash maps and sets · routine

First unique character

Write first_unique(text) returning the index of the first character that appears exactly once, or -1 if there is none.

Run adds print(first_unique("leetcode")) after your code, to try it.

Stuck on the idea rather than the code? The Hash maps and sets lesson walks through it.