linkjobai / Topological Sort in Coding Interviews: Kahn's Algorithm Explained
0 лайк(-ов)
0 форк(-ов)
1 файл(-ов)
Последняя активность 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)
Новее
Позже