Back to Amazon
Coding rounds
Amazon coding rounds
5 timed coding challenges drawn from real loops. Submit a solution to see your test pass rate and AI feedback.
←All coding rounds
advanced 45:00+130 XP
Course Schedule
There are `numCourses` labeled 0..numCourses-1. `prerequisites[i] = [a, b]` means you must take course `b` before course `a`. Return true if you can finish all courses. Detect a cycle in the dependency graph (topological sort / Kahn’s algorithm).
Examples
take 0 then 1
in: numCourses=2, prerequisites=[[1,0]]
out: true
cyclic dependency
in: numCourses=2, prerequisites=[[1,0],[0,1]]
out: false
javascript
Loading editor...