0 day streak
Anonymous · shared experience20 Feb 2026 · 12 views

Paytm: O(1) LRU cache, then thread safety and why not a built-in linked map

Interview question #Paytm DSA / coding

Problem. Implement a least-recently-used cache with get and put, both in O(1) time. When the cache is full, inserting a new key evicts the entry that was used least recently.

Edge cases they wanted covered. Updating the value of a key that already exists, which should also refresh its recency, and correct eviction at capacity.

Follow-ups.

  • How would you make the cache safe under concurrent access?
  • Why build it yourself instead of using the language's built-in insertion-ordered or access-ordered linked hash map?
  • Where would you use a cache like this in a real system, for example in front of a database?

What the interviewer cared about. Clean, modular code and the thought process: trade-offs, optimizations and edge cases mattered more than just getting it to pass. The role was technical lead, and a dependency-graph cycle-detection problem came in the same round.

0 comments

Comments 0

No comments yet. Ask the author something, or add what happened in your own round.