← Discussions on First Unique Character
K krishnahegde
17 Aug 2026, 16:51

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

aksharakulkarni 1 month, 3 weeks ago

You can avoid the extra array and do it in O(1) space.

Sign in to reply.