Back to all patterns

Topological Sort

2 problems • Practice on LeetCode to earn credits

About This Pattern

Master the Topological Sort pattern by practicing these problems organized by difficulty.Focus on the Key Signals - these are the indicators that tell you when to use this pattern.

Medium (1)

Course Schedule II

Return ordering of courses to take (topological sort).

Key Signals:

DFS post-orderOr BFS with in-degreeReturn reverse order

Hard (1)

Alien Dictionary

Derive the order of characters in an alien language from sorted words.

Key Signals:

Build graph from adjacent wordsTopological sortDetect invalid