← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Amazon SWE coding round, basically a graph cycle detection problem dressed up as a course scheduling question. Pretty standard stuff if you've done any leetcode graph problems before.

Questions Asked (1)

Q1

Given a directed graph of course prerequisites, write a function to determine whether it's possible to complete all n courses without hitting a cycle.

Algorithms & Data Structures
Author's notes

Basically course schedule from leetcode 207.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the courses 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 approach, walk through a small example, and analyze time and space complexity.

Pro tip: Mention that this is essentially cycle detection in a directed graph, and that Kahn's algorithm is often preferred in interviews because it's iterative and avoids recursion depth issues. Also, clarify edge cases like duplicate prerequisites or self-loops.

1. Clarify the problem

Confirm that the input is a directed graph where an edge from course A to course B means A is a prerequisite for B, and that we need to check if all courses can be completed (i.e., no cycles).

2. Choose an algorithm

Decide between Kahn's algorithm (BFS-based topological sort) and DFS with cycle detection. Explain why you chose one over the other.

3. Walk through the algorithm

Describe the steps of the chosen algorithm, such as computing in-degrees and using a queue for Kahn's, or using a visited set and recursion stack for DFS.

4. Analyze complexity

State the time and space complexity: O(V + E) time and O(V + E) space for both approaches.

5. Handle edge cases

Discuss edge cases like empty graph, self-loops, duplicate edges, and disconnected components.

Key Points to Mention

  • Cycle detection in directed graphs
  • Topological sorting
  • Kahn's algorithm (BFS-based)
  • DFS with recursion stack
  • Time and space complexity O(V + E)
  • Edge cases: self-loops, duplicate edges, disconnected components

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