Problem
Given n courses and prerequisites, return a valid ordering of courses to finish all of them. Return empty array if impossible.
References
Difficulty
🟡 Medium
Companies
Amazon, Microsoft, PhonePe
Notes
Language: Java
Topological sort returning the actual order. Kahn's algorithm (BFS with in-degree) naturally produces the order. DFS approach reverses the finish order.
Problem
Given n courses and prerequisites, return a valid ordering of courses to finish all of them. Return empty array if impossible.
References
Difficulty
🟡 Medium
Companies
Amazon, Microsoft, PhonePe
Notes
Language: Java
Topological sort returning the actual order. Kahn's algorithm (BFS with in-degree) naturally produces the order. DFS approach reverses the finish order.