Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Design an LRU Cache

MediumPython00:00
Capgemini FSSBU
Your interviewer · Solutions Architect
In session
Interviewer

Welcome to the Python screen for the Solutions Architect role at Capgemini FSSBU.

The question is on your right: Design an LRU Cache. Read through the requirements first.

Would you like to talk through your approach, or are you ready to start coding?

Talking through your plan before coding is graded well.

Problem

Implement an LRU cache with fixed capacity. Support get(key) and put(key, value) so that both run in O(1) average time, and evict the least recently used key when the cache is full.

Constraints

  • 1 <= capacity <= 3000
  • 0 <= key <= 10^4
  • 0 <= value <= 10^5
  • Up to 2 * 10^5 operations
Your solutionPython 3
Run as often as you like, then submit when the output looks right.
Run your code to see test output