Topological Sort LeetCode Problems: All 32,
With Python Solutions
Every problem in this library that LeetCode tags Topological Sort. 24 of them carry a complete Python solution, a worked example and the time and space complexity of the approach.
- Easy
- 0
- Medium
- 14
- Hard
- 18
How Topological Sort problems are solved
A tag names the subject, not the method. These pattern hubs cover the techniques that actually solve Topological Sort problems — each one explains the approach, gives a Python template and states its complexity.
Eyes only
When the Topological Sort problem arrives live.
In the live round, Stealth Interview reads the problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer says. It's a desktop app for macOS and Windows, invisible to screen sharing.
Topological Sort problems by difficulty
Problems with a complete Python solution are listed first, then by ascending problem number.
Medium (14)
| No. | Problem | Topics |
|---|---|---|
| 0207 | Course Schedule | |
| 0210 | Course Schedule II | |
| 0310 | Minimum Height Trees | |
| 0802 | Find Eventual Safe States | |
| 0851 | Loud and Rich | |
| 1462 | Course Schedule IV | |
| 1786 | Number of Restricted Paths From First to Last Node | |
| 1976 | Number of Ways to Arrive at Destination | |
| 2115 | Find All Possible Recipes from Given Supplies | |
| 2192 | All Ancestors of a Node in a Directed Acyclic Graph | |
| 0444 | Sequence ReconstructionPremium | |
| 1059 | All Paths from Source Lead to DestinationPremium | |
| 1136 | Parallel CoursesPremium | |
| 1245 | Tree DiameterPremium |
Hard (18)
Keep exploring
Other topics
- Array1,569
- String672
- Hash Table588
- Math485
- Dynamic Programming481
- Sorting392
- Greedy346
- Depth-First Search289
- Binary Search253
- Database249
- Tree225
- Breadth-First Search223
- Matrix216
- Two Pointers201
- Bit Manipulation194
- Binary Tree174
- Heap (Priority Queue)163
- Prefix Sum157
- Stack157
- Simulation144
- Graph138
- Counting126
- Design122
- Sliding Window116