Graphs (Topological Sort)
Medium

Course Schedule II

Return the ordering of courses you should take to finish all courses.
Problem Understanding

Same as Course Schedule I, but return the order (any valid topological sort). If impossible, return an empty array.

Interactive Visualization
Step 1 / 1

Visualization coming soon...

Initializing...

1x
See the Logic in Motion
Stop memorizing code. Unlock the full interactive visualizer to master the logic step-by-step.
Unlock VisualizerPREMIUM FEATURE

Stop Guessing, Start Mastering.

Build the FAANG intuition. Master this pattern with optimized implementations, visual dry runs, and our curated collection of high-yield problems.

Start Your Premium Prep