3. How does a hash map work, and what happens on a collision?
MediumData structures & algorithms
TechnicalAtlassian guide
Sources & context
- Atlassian engineering interview handbook
Official engineering guidance covers data structures, code design and systems design. Related practice format; not an exact employer question.
Show model answer
A hash map applies a hash function to the key to pick a bucket in an array, giving average O(1) insert, lookup and delete.
Collisions (two keys in one bucket) are handled by chaining (a small list per bucket) or open addressing (probing for another slot). When the load factor gets high, the table resizes and rehashes. A poor hash function or adversarial keys can degrade operations to O(n).
What interviewers listen for
- Average O(1), worst O(n)
- Load factor and resizing
- Keys need consistent hashing and equality