← All questions
Coding
HashMap + Doubly Linked List
Asked at
Microsoft
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01State the O(1) get and put contract
- 02Map each key to its linked-list node
- 03Keep most-recent and least-recent entries at opposite ends with sentinels
- 04On access, detach then move the node to the recent end
- 05On overflow, remove the least-recent real node and delete its map entry
Reference answer
Then expect these follow-ups
What constraint would change your chosen approach?
Tests: constraint adaptation
How would you test the edge cases before implementation?
Tests: implementation extension
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question