linkjobai / Topological Sort in Coding Interviews: Kahn's Algorithm Explained
0 beğeniler
0 çatallar
1 dosyalar
Son aktivite 5 days ago
Interview prep notes
Topological Sort in Coding Interviews: Kahn's Algorithm Explained
Problems like Course Schedule (LeetCode 207/210), Alien Dictionary and build-order questions are all the same idea: you have tasks with "must happen before" rules, and you need a valid order (or proof that none exists).
The idea in one sentence
Repeatedly take a node with no remaining prerequisites (in-degree 0), output it, and remove its outgoing edges.
Python template (Kahn's algorithm)
Daha yeni
Daha eski