Skip to main content
Intermediate~6 min · +40 XP

Hash Map: First Unique

Practices: Hash Tables & Sets

Problem

String: "aabbcd". Using one pass to count frequencies and a second pass to scan for the first character with count 1,

which INDEX holds the first unique character?

Examples

  • in: "aabc"

    out: 2

    a appears twice; the first count-1 character is b at index 2.

Constraints & conventions

  • 0-indexed positions.

Your answer

Solve the challenge to unlock the full approach and complexity analysis.