Implement LRU Cache
Asked at Palo Alto Networks · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026
Implement a LRU (Least Recently Used) cache. This class must support the `get` and `put` methods. Each `get` or `put` operation should be executed in O(1) time complexity. The cache capacity is provided at initialization, and when reaching the limit, invalidate the least recently used item before adding a new one. In the `put` method, if a new element already exists, its value needs to be updated. Please provide full interface specifications and test cases.
Loading the problem…
More Palo Alto Networks interview questions
- Understanding Cross-Origin Issues and Their Solutions
- Prime Number of Set Bits in Binary Representation
- Design and Implement a Thread-Safe Rate Limiter (Handle High QPS)
- JavaScript Singleton Pattern Implementation
- Seat Every Couple Together with the Fewest Swaps
- BFS problem (unspecified)