Backend Engineering
Senior
programming
LeetCode #146 - LRU Cache: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get(key) and put(key, value). The order of the keys and the constraints on memory usage are crucial.
```
class LRUCache:
def __init__(self, capacity: int):
# Initialize the cache and its capacity
def get(self, key: int) -> int:
# Return the value of the key if the key exists in the cache, otherwise return -1
def put(self, key: int, value: int) -> None:
# Update the value or insert the key-value pair if not already present
```
Trusted by 100+ professionals preparing for interviews
Trusted by 100+ professionals
50+ Company Question Banks
5+ Supported Languages
Practice More Questions Like This
Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.
Get Started Free
More Backend Engineering Interview Prep
In a microservices architecture, how do you approach designing the communication between services? What protocols do you consider and why?
Backend Engineering · Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.