Loading section...
LRU Cache with OrderedDict — The Gate Question
This is the question that filters mid-level from senior DE candidates more consistently than any other dict problem. 'Implement an LRU cache with O(1) get and put.' Candidates who don't know OrderedDict's move_to_end() and popitem(last=False) cannot solve it in O(1) — they either use a list (O(n) for repositioning) or rebuild the dict entirely. Knowing these two methods is a hard gate. The Full Implementation Python 3.9+ lru_cache Alternative