← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Third round coding interview at eBay for a software engineer role. One question, LRU Cache, Indian interviewer. Pretty standard as far as these go.

Questions Asked (1)

Q1

Design and implement an LRU (Least Recently Used) cache with get and put operations, both running in O(1) time.

Algorithms & Data Structures
Author's notes

Classic problem, I'd done it before, but there's always that moment where you second-guess whether to reach for a doubly linked list plus hashmap or try to get clever.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then propose using a hash map combined with a doubly linked list to achieve O(1) operations. Explain the design, walk through an example, and discuss edge cases and potential optimizations.

Pro tip: Mention that you would use a doubly linked list to maintain recency order and a hash map for O(1) access, and highlight that this is a common design for systems like databases and caches. Also, discuss thread-safety if the cache might be accessed concurrently.

1. Clarify requirements

Ask about expected cache size, eviction policy details, and whether thread-safety is needed. Confirm that both get and put must be O(1).

2. Propose data structures

Suggest using a hash map for O(1) key lookup and a doubly linked list to track usage order. Explain how they work together.

3. Detail operations

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

4. Walk through an example

Trace through a sequence of get and put operations to demonstrate correctness and O(1) behavior.

5. Discuss edge cases and optimizations

Cover scenarios like cache size 0 or 1, updating existing keys, and potential thread-safety using locks or concurrent data structures.

Key Points to Mention

  • Hash map provides O(1) access to cache nodes.
  • Doubly linked list maintains recency order with O(1) insertions and deletions.
  • Eviction policy: remove the least recently used item (tail of the list).
  • Updating an existing key should also move it to the front.
  • Thread-safety considerations if the cache is shared across threads.
  • Time and space complexity: O(1) for get and put, O(capacity) space.

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