← Citadel Interview Insights

Citadel·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Citadel coding round, pretty standard algo stuff. Got an LRU cache question which I'd seen before but still fumbled parts of the implementation under pressure.

Questions Asked (1)

Q1

Implement an LRU cache with get and put operations, both in O(1) average time. When the cache is full, evict the least recently used entry.

Algorithms & Data StructuresSystem Design
Author's notes

I knew the answer going in, hash map plus doubly linked list, but translating that into clean code on the spot was rougher than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: O(1) get and put, eviction of least recently used when full. Then propose a combination of a hash map for O(1) access and a doubly linked list to maintain usage order, explaining how operations update the list. Finally, discuss edge cases and potential optimizations like thread safety.

Pro tip: Mention that you'd use a doubly linked list with sentinel head and tail nodes to simplify edge cases, and discuss how you'd handle concurrency if needed, showing awareness of real-world systems.

1. Clarify requirements and constraints

Confirm the operations (get, put), time complexity (O(1) average), eviction policy (LRU), and any additional constraints like thread safety or capacity limits.

2. Choose data structures

Select a hash map for O(1) key lookup and a doubly linked list to track access order, where the head is most recently used and tail is least recently used.

3. Define operations

For get: if key exists, move node to head and return value; else return -1. For put: if key exists, update value and move to head; else create new node, add to head, and if capacity exceeded, remove tail node and its key from map.

4. Handle edge cases

Consider capacity 0 or 1, updating existing keys, and ensuring the map and list stay in sync. Use sentinel nodes to avoid null checks.

5. Discuss optimizations and extensions

Mention thread safety (e.g., using locks or concurrent data structures), and possible variations like LFU or time-based eviction.

Key Points to Mention

  • Hash map provides O(1) average time for key lookup.
  • Doubly linked list allows O(1) removal and insertion, and maintains access order.
  • Sentinel head and tail nodes simplify boundary conditions.
  • On get, move accessed node to head to mark as most recently used.
  • On put, if capacity is full, evict tail node (least recently used) and remove its key from map.
  • Consider thread safety for concurrent access, e.g., using a mutex or ConcurrentHashMap with synchronization.

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