← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePass
Apr 2026

Summary

eBay coding round for a Software Engineer role, graph-based LeetCode questions. Went smoothly, solved both without much trouble.

Questions Asked (1)

Q1

Given a list of courses and their prerequisites, determine whether it's possible to finish all courses (course schedule / cycle detection in a directed graph).

Algorithms & Data Structures
Author's notes

Both problems were essentially the same pattern so once I got the first one down the second was just a variation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the courses and prerequisites as a directed graph where an edge from prerequisite to course indicates dependency. Then detect if the graph contains a cycle using either Kahn's algorithm (BFS topological sort) or DFS with recursion stack. If a cycle exists, it's impossible to finish all courses; otherwise, it's possible.

Pro tip: Discuss both BFS and DFS approaches, mentioning their time and space complexities, and explain why cycle detection is equivalent to checking if a topological ordering exists. Also, clarify edge cases like duplicate prerequisites or disconnected graphs.

1. Understand the problem

Restate the problem: given numCourses and a list of prerequisite pairs, determine if all courses can be finished. Clarify that a cycle in the prerequisite graph makes it impossible.

2. Model as a graph

Represent courses as nodes and prerequisites as directed edges. For each pair [a, b] meaning b is prerequisite for a, add edge b -> a. Build an adjacency list and optionally an in-degree array.

3. Choose cycle detection algorithm

Select either Kahn's algorithm (BFS topological sort) or DFS with recursion stack. Explain the chosen method's steps and why it detects cycles.

4. Implement and analyze

Write code for the chosen algorithm, ensuring to handle disconnected components. Analyze time complexity O(V+E) and space complexity O(V+E).

5. Test and conclude

Test with cases: no prerequisites, simple cycle, complex graph. Conclude that if no cycle is found, all courses can be finished.

Key Points to Mention

  • Graph representation: adjacency list and in-degree array for Kahn's algorithm.
  • Cycle detection via topological sort: if processed nodes count equals numCourses, no cycle.
  • DFS approach: use visited states (unvisited, visiting, visited) to detect back edges.
  • Time and space complexity: O(V+E) for both BFS and DFS.
  • Handling disconnected graphs: loop over all nodes to ensure all components are checked.
  • Edge cases: empty prerequisites, duplicate edges, self-loops.

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