First Non-Repeating Character

Hash Maps ยท medium

Implement `firstUnique(str)` that returns the index of the first character in `str` that appears only once. Return `-1` if none exists.

Hints
  • Two-pass approach: first count all characters, then find the first with count 1.

Learning resources

Loading...

Run your code to see results.