Back to DashboardUpgrade
Pro pattern
Upgrade to Pro to access this pattern and all 22 patterns.
PATTERN
Topological Sort
Order nodes in a directed acyclic graph (DAG) so every edge points forward. Master cycle detection, Kahn's algorithm (BFS), and DFS post-order reversal for dependency ordering, course scheduling, and alien dictionaries.
Learn Topological SortExplanation, templates & reference