Arrays & Hashing Interview Questions & Solutions

20 solutions ยท 11 Easy ยท 8 Medium ยท 1 Hard

If there's one trick that turns slow interview solutions into fast ones, it's hashing. The move is almost always the same: instead of scanning the array again to check whether you've seen a value, you store what you've seen in a hash map or set and check in O(1). That single idea collapses countless O(nยฒ) brute forces into clean O(n) passes โ€” and interviewers expect you to reach for it instinctively.

These solutions show the pattern in all its common disguises: two-sum and its complement lookup, grouping anagrams by a canonical key, counting frequencies, finding duplicates, and detecting whether two structures match by comparing counts rather than elements. You'll also see when a plain set beats a map, and the classic space-for-time trade-off stated plainly so you can defend it when the interviewer asks about memory. Internalize this handful of problems and you'll spot the "just use a hash map" opening in problems that look much harder at first glance.

Practice Arrays & Hashing the right way

SkillFlow serves you Arrays & Hashing problems matched to your level, times you like a real interview, and tracks your proficiency as it climbs. Free.

Start practicing free โ†’

Other interview patterns