← Discussions on First Unique Character
K kavyanaidu
21 Jul 2026, 05:12

Intuition + complexity breakdown for First Unique Character.

Use a hash map from value to index (or count). For each element check whether its complement is already in the map, then insert it. That makes it O(n) instead of the O(n²) brute force.

1 reply

kgoud 2 months, 3 weeks ago

Great explanation, the edge case with an empty input tripped me up too.

Sign in to reply.