← eBay Interview Insights

eBay·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Three coding problems for an eBay software engineer round. Pretty classic leetcode territory but they stacked them back to back which made the pacing rough. No behavioral stuff, just code.

Questions Asked (3)

Q1

Given a number of tasks and a list of prerequisite pairs, determine whether all tasks can be completed (i.e. detect if the dependency graph contains a cycle).

Algorithms & Data Structures
Author's notes

Cycle detection in a directed graph.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the tasks and prerequisites as a directed graph and detect cycles using either Kahn's algorithm (BFS-based topological sort) or DFS with recursion stack. Explain the chosen algorithm, its time and space complexity, and how it determines if all tasks can be completed.

Pro tip: Mention that Kahn's algorithm is often preferred in interviews because it's iterative (avoids recursion depth issues) and can also produce a valid order if needed. Also, clarify that the graph is directed and edges go from prerequisite to dependent task.

1. Clarify the problem

Confirm that tasks are nodes and prerequisites are directed edges. Ask if the graph is guaranteed to be connected or if there are multiple components.

2. Choose an algorithm

Decide between Kahn's algorithm (BFS) and DFS with cycle detection. Explain why one is more suitable (e.g., iterative vs recursive).

3. Implement the algorithm

For Kahn's: compute in-degrees, use a queue, and count processed nodes. For DFS: track visited and recursion stack to detect back edges.

4. Analyze complexity

State that time complexity is O(V+E) and space complexity is O(V+E) for storing the graph and auxiliary data structures.

5. Handle edge cases

Discuss cases like no prerequisites, disconnected components, and self-loops. Mention that if processed count equals total tasks, all can be completed.

Key Points to Mention

  • Directed graph representation (adjacency list)
  • Cycle detection via topological sorting
  • Kahn's algorithm (BFS) with in-degree tracking
  • DFS with recursion stack (white-gray-black coloring)
  • Time and space complexity O(V+E)
  • Edge cases: empty graph, self-loop, disconnected components

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

Q2

Design a data structure that supports inserting words and querying by exact match or by prefix.

Algorithms & Data StructuresSystem Design
Author's notes

Trie.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: operations needed (insert, exact match, prefix query), expected data volume, and performance constraints. Then propose a trie as the core data structure, explaining how it supports both operations efficiently. Discuss trade-offs and potential optimizations like using a hash map for exact matches or a compressed trie for space efficiency.

Pro tip: Mention that in real-world systems like eBay's search, tries are often combined with other structures (e.g., inverted indexes) and that you'd consider memory vs. speed trade-offs, showing you think beyond the textbook answer.

1. Clarify Requirements

Ask about the expected number of words, query frequency, memory constraints, and whether case sensitivity or special characters matter. This ensures your solution aligns with the actual use case.

2. Propose a Trie

Explain that a trie (prefix tree) naturally supports prefix queries and exact matches by traversing nodes character by character. Insertion and search are O(L) where L is word length.

3. Detail Operations

Describe insert: traverse/create nodes for each character, mark end-of-word. Exact match: traverse and check end-of-word flag. Prefix query: traverse to prefix end, then collect all words in subtree (e.g., via DFS).

4. Discuss Optimizations and Trade-offs

Mention alternatives like hash maps for exact match (O(1) average) but not prefix; or ternary search trees for space efficiency. Consider memory overhead of tries and possible compression (radix tree).

5. Handle Edge Cases and Extensions

Address empty strings, duplicate insertions, and deletion. For large-scale systems, discuss distributed tries or combining with caching for frequent prefixes.

Key Points to Mention

  • Trie (prefix tree) structure and its time complexity O(L) for insert/search
  • Exact match can be optimized with a hash map if prefix queries are not needed
  • Space-time trade-offs: tries use more memory but enable fast prefix queries
  • Handling of end-of-word markers to distinguish complete words from prefixes
  • Potential optimizations: compressed tries (radix trees) to reduce memory
  • Scalability considerations for large datasets (e.g., sharding, caching)

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

Q3

Implement a fixed-capacity cache that evicts the least recently used item when full, with O(1) get and put operations.

Algorithms & Data StructuresSystem Design
Author's notes

LRU cache with a hashmap plus doubly linked list.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (fixed capacity, O(1) get/put, eviction policy). Then propose a hash map combined with a doubly linked list to achieve O(1) operations, and walk through the implementation details, including edge cases and potential optimizations.

Pro tip: Mention that you would use a sentinel head and tail in the doubly linked list to simplify edge cases and avoid null checks, and discuss thread-safety if the cache is used in a concurrent environment.

1. Clarify Requirements

Confirm the cache capacity, eviction policy (LRU), and operation complexity (O(1)). Ask about concurrency requirements and whether the cache needs to be thread-safe.

2. Choose Data Structures

Select a hash map for O(1) key lookup and a doubly linked list to maintain access order. Explain how the hash map stores key to node references, and the linked list stores nodes with key-value pairs.

3. Define Operations

Detail the get and put operations: for get, move the accessed node to the front (most recently used); for put, insert new node at front, and if capacity exceeded, remove the tail node (least recently used) and update the hash map.

4. Handle Edge Cases

Discuss edge cases: updating an existing key, cache capacity of 0 or 1, and handling null keys/values if applicable. Mention using sentinel nodes to simplify list operations.

5. Analyze Complexity and Optimizations

Confirm O(1) time for both operations and O(capacity) space. Optionally discuss thread-safety using locks or concurrent data structures, and potential optimizations like using a custom linked list for performance.

Key Points to Mention

  • Hash map provides O(1) access to cache nodes.
  • Doubly linked list maintains recency order with O(1) insertion/deletion.
  • Sentinel nodes (dummy head and tail) simplify edge cases.
  • Eviction removes the least recently used node (tail).
  • Thread-safety considerations: use locks or ConcurrentHashMap with synchronized blocks.
  • Time complexity: O(1) for get and put; space complexity: O(capacity).

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