# Topological Sort DSA Problems

> 36 Topological Sort coding problems for placements and interviews, sorted easiest first, with hints and company tags. Free practice on InternHack.

Canonical: https://www.internhack.in/learn/dsa/topological-sort
Last updated: 2026-11-28

36 topological sort problems for coding interviews and campus placements, with hints and company tags. Below are all 36: 0 easy, 15 medium and 21 hard. Practise them free on InternHack and track what you have solved.

## Topological Sort problems, easiest first

1. [All Ancestors of a Node in a Directed Acyclic Graph](https://www.internhack.in/learn/dsa/problem/all-ancestors-of-a-node-in-a-directed-acyclic-graph) (Medium)
2. [All Paths from Source Lead to Destination](https://www.internhack.in/learn/dsa/problem/all-paths-from-source-lead-to-destination) (Medium)
3. [Apply Substitutions](https://www.internhack.in/learn/dsa/problem/apply-substitutions) (Medium)
4. [Course Schedule](https://www.internhack.in/learn/dsa/problem/course-schedule) (Medium)
5. [Course Schedule II](https://www.internhack.in/learn/dsa/problem/course-schedule-ii) (Medium)
6. [Course Schedule IV](https://www.internhack.in/learn/dsa/problem/course-schedule-iv) (Medium)
7. [Find All Possible Recipes from Given Supplies](https://www.internhack.in/learn/dsa/problem/find-all-possible-recipes-from-given-supplies) (Medium)
8. [Find Eventual Safe States](https://www.internhack.in/learn/dsa/problem/find-eventual-safe-states) (Medium)
9. [Loud and Rich](https://www.internhack.in/learn/dsa/problem/loud-and-rich) (Medium)
10. [Minimum Height Trees](https://www.internhack.in/learn/dsa/problem/minimum-height-trees) (Medium)
11. [Number of Restricted Paths From First to Last Node](https://www.internhack.in/learn/dsa/problem/number-of-restricted-paths-from-first-to-last-node) (Medium)
12. [Number of Ways to Arrive at Destination](https://www.internhack.in/learn/dsa/problem/number-of-ways-to-arrive-at-destination) (Medium)
13. [Parallel Courses](https://www.internhack.in/learn/dsa/problem/parallel-courses) (Medium)
14. [Sequence Reconstruction](https://www.internhack.in/learn/dsa/problem/sequence-reconstruction) (Medium)
15. [Tree Diameter](https://www.internhack.in/learn/dsa/problem/tree-diameter) (Medium)
16. [Alien Dictionary](https://www.internhack.in/learn/dsa/problem/alien-dictionary) (Hard)
17. [Build a Matrix With Conditions](https://www.internhack.in/learn/dsa/problem/build-a-matrix-with-conditions) (Hard)
18. [Cat and Mouse](https://www.internhack.in/learn/dsa/problem/cat-and-mouse) (Hard)
19. [Cat and Mouse II](https://www.internhack.in/learn/dsa/problem/cat-and-mouse-ii) (Hard)
20. [Collect Coins in a Tree](https://www.internhack.in/learn/dsa/problem/collect-coins-in-a-tree) (Hard)
21. [Count Ways to Build Rooms in an Ant Colony](https://www.internhack.in/learn/dsa/problem/count-ways-to-build-rooms-in-an-ant-colony) (Hard)
22. [Design Excel Sum Formula](https://www.internhack.in/learn/dsa/problem/design-excel-sum-formula) (Hard)
23. [Distance to a Cycle in Undirected Graph](https://www.internhack.in/learn/dsa/problem/distance-to-a-cycle-in-undirected-graph) (Hard)
24. [Frequencies of Shortest Supersequences](https://www.internhack.in/learn/dsa/problem/frequencies-of-shortest-supersequences) (Hard)
25. [Largest Color Value in a Directed Graph](https://www.internhack.in/learn/dsa/problem/largest-color-value-in-a-directed-graph) (Hard)
26. [Longest Cycle in a Graph](https://www.internhack.in/learn/dsa/problem/longest-cycle-in-a-graph) (Hard)
27. [Longest Increasing Path in a Matrix](https://www.internhack.in/learn/dsa/problem/longest-increasing-path-in-a-matrix) (Hard)
28. [Longest Path With Different Adjacent Characters](https://www.internhack.in/learn/dsa/problem/longest-path-with-different-adjacent-characters) (Hard)
29. [Maximum Employees to Be Invited to a Meeting](https://www.internhack.in/learn/dsa/problem/maximum-employees-to-be-invited-to-a-meeting) (Hard)
30. [Minimize Maximum Value in a Grid](https://www.internhack.in/learn/dsa/problem/minimize-maximum-value-in-a-grid) (Hard)
31. [Minimum Runes to Add to Cast Spell](https://www.internhack.in/learn/dsa/problem/minimum-runes-to-add-to-cast-spell) (Hard)
32. [Number of Increasing Paths in a Grid](https://www.internhack.in/learn/dsa/problem/number-of-increasing-paths-in-a-grid) (Hard)
33. [Parallel Courses III](https://www.internhack.in/learn/dsa/problem/parallel-courses-iii) (Hard)
34. [Rank Transform of a Matrix](https://www.internhack.in/learn/dsa/problem/rank-transform-of-a-matrix) (Hard)
35. [Sort Items by Groups Respecting Dependencies](https://www.internhack.in/learn/dsa/problem/sort-items-by-groups-respecting-dependencies) (Hard)
36. [Strange Printer II](https://www.internhack.in/learn/dsa/problem/strange-printer-ii) (Hard)

## Companies that ask topological sort problems

- [Google](https://www.internhack.in/learn/dsa/companies/google): 29 of these problems
- [Amazon](https://www.internhack.in/learn/dsa/companies/amazon): 22 of these problems
- [Meta](https://www.internhack.in/learn/dsa/companies/meta): 17 of these problems
- [Microsoft](https://www.internhack.in/learn/dsa/companies/microsoft): 17 of these problems
- [Uber](https://www.internhack.in/learn/dsa/companies/uber): 10 of these problems
- [Tiktok](https://www.internhack.in/learn/dsa/companies/tiktok): 9 of these problems
- [Bloomberg](https://www.internhack.in/learn/dsa/companies/bloomberg): 8 of these problems
- [Oracle](https://www.internhack.in/learn/dsa/companies/oracle): 7 of these problems
- [Phonepe](https://www.internhack.in/learn/dsa/companies/phonepe): 6 of these problems
- [Citadel](https://www.internhack.in/learn/dsa/companies/citadel): 6 of these problems
- [Apple](https://www.internhack.in/learn/dsa/companies/apple): 5 of these problems
- [Salesforce](https://www.internhack.in/learn/dsa/companies/salesforce): 5 of these problems

## Before your interview

Most resumes are filtered by software before a recruiter reads them. [Check your resume ATS score free](https://www.internhack.in/ats-score/try), no signup needed.

## Other DSA topics

- [Array](https://www.internhack.in/learn/dsa/array) (1869)
- [String](https://www.internhack.in/learn/dsa/string) (775)
- [Hash Table](https://www.internhack.in/learn/dsa/hash-table) (708)
- [Math](https://www.internhack.in/learn/dsa/math) (564)
- [Dynamic Programming](https://www.internhack.in/learn/dsa/dynamic-programming) (557)
- [Sorting](https://www.internhack.in/learn/dsa/sorting) (464)
- [Greedy](https://www.internhack.in/learn/dsa/greedy) (407)
- [Depth-First Search](https://www.internhack.in/learn/dsa/depth-first-search) (314)
- [Binary Search](https://www.internhack.in/learn/dsa/binary-search) (298)
- [Matrix](https://www.internhack.in/learn/dsa/matrix) (246)
- [Breadth-First Search](https://www.internhack.in/learn/dsa/breadth-first-search) (245)
- [Bit Manipulation](https://www.internhack.in/learn/dsa/bit-manipulation) (238)
- [Tree](https://www.internhack.in/learn/dsa/tree) (235)
- [Two Pointers](https://www.internhack.in/learn/dsa/two-pointers) (217)
- [Prefix Sum](https://www.internhack.in/learn/dsa/prefix-sum) (204)
- [Database](https://www.internhack.in/learn/dsa/database) (197)
- [Heap (Priority Queue)](https://www.internhack.in/learn/dsa/heap-priority-queue) (196)
- [Simulation](https://www.internhack.in/learn/dsa/simulation) (177)
- [Counting](https://www.internhack.in/learn/dsa/counting) (174)
- [Binary Tree](https://www.internhack.in/learn/dsa/binary-tree) (169)

## Related

- [Home](https://www.internhack.in/)
- [Learn](https://www.internhack.in/learn)
- [DSA](https://www.internhack.in/learn/dsa)
