← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Went through a coding round at Uber for a software engineer role, got hit with LRU cache. Pretty standard but still worth knowing where you stand on the implementation details.

Questions Asked (1)

Q1

Implement an LRU (Least Recently Used) cache with get and put operations in O(1) time.

Algorithms & Data Structures
Author's notes

Classic problem but the O(1) constraint is what trips people up if they haven't seen it before.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements and constraints, then propose a design using a hash map for O(1) access and a doubly linked list for O(1) eviction. Walk through the implementation details, including edge cases, and analyze time and space complexity.

Pro tip: Mention that this is a classic system design question and that you would consider thread-safety if the cache is used in a concurrent environment, showing awareness of real-world usage.

1. Clarify requirements

Ask about cache capacity, expected operations, and whether thread-safety is needed. Confirm that get and put must be O(1).

2. Propose data structures

Explain that a hash map provides O(1) access to nodes, and a doubly linked list maintains recency order for O(1) updates and evictions.

3. Detail operations

Describe how get moves the accessed node to the front, and put adds or updates a node, evicting the least recently used (tail) when capacity is exceeded.

4. Handle edge cases

Discuss handling of capacity 0 or 1, updating existing keys, and ensuring the list and map stay in sync.

5. Analyze complexity

Conclude that both operations are O(1) time and O(capacity) space, and mention potential optimizations like using a sentinel head/tail.

Key Points to Mention

  • Hash map for O(1) key lookup
  • Doubly linked list for O(1) node removal and insertion
  • Moving accessed nodes to the front (most recently used)
  • Evicting the least recently used node from the tail when capacity is exceeded
  • Handling edge cases like capacity 0 or 1, and updating existing keys
  • Time and space complexity analysis: O(1) per operation, O(capacity) space

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.