LeetCodechevron_rightCategorieschevron_righttopological sort
low_priority

topological sort

28 problems
Easy: 0Medium: 10Hard: 18

topological sort is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.

Interview Signal

Frequently tests problem modeling, edge handling, and verbal clarity.

Common Pitfall

Template-only answers break under follow-up questioning.

Practice Strategy

Practice in 3-5 problem rounds and always review complexity alternatives.

Recommended Progression

#TitleDifficulty
207

Course Schedule

Determine if all courses can be completed by analyzing prerequisite dependencies using indegree tracking and topological…

Medium
210

Course Schedule II

Solve the 'Course Schedule II' problem using graph indegree and topological ordering, utilizing DFS or BFS to find the c…

Medium
310

Minimum Height Trees

Identify all roots of a tree that produce minimum height using graph indegree analysis and topological trimming.

Medium
329

Longest Increasing Path in a Matrix

Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.

Hard
802

Find Eventual Safe States

Solve the problem of finding eventual safe states in a directed graph using depth-first search and topological sorting.

Medium
851

Loud and Rich

Determine the quietest person richer than each individual using graph indegree analysis and topological ordering techniq…

Medium
913

Cat and Mouse

Determine the outcome of a two-player Cat and Mouse game on a graph using topological ordering and memoized dynamic prog…

Hard
1203

Sort Items by Groups Respecting Dependencies

Sort items into groups while respecting dependencies using graph indegree tracking and topological ordering patterns eff…

Hard
1462

Course Schedule IV

Determine if one course is a prerequisite of another using graph indegree tracking and topological ordering efficiently.

Medium
1591

Strange Printer II

Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…

Hard
1632

Rank Transform of a Matrix

Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…

Hard
1728

Cat and Mouse II

Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…

Hard
1786

Number of Restricted Paths From First to Last Node

Solve the problem of finding the number of restricted paths in a weighted undirected graph, leveraging graph algorithms …

Medium
1857

Largest Color Value in a Directed Graph

Compute the maximum color frequency along any valid path in a directed graph using topological ordering and dynamic prog…

Hard
1916

Count Ways to Build Rooms in an Ant Colony

Solve the problem of counting distinct ways to build rooms in an ant colony using dynamic programming and topological or…

Hard
1976

Number of Ways to Arrive at Destination

Find the number of ways to travel from intersection 0 to n - 1 in the shortest time, using a graph-based approach.

Medium
2050

Parallel Courses III

Solve Parallel Courses III by finding the minimum number of months to complete all courses using graph-based topological…

Hard
2115

Find All Possible Recipes from Given Supplies

Determine all recipes you can prepare given initial supplies and ingredient dependencies, leveraging array scanning and …

Medium
2127

Maximum Employees to Be Invited to a Meeting

Determine the maximum employees to invite based on favorite adjacency constraints using graph indegree and topological o…

Hard
2192

All Ancestors of a Node in a Directed Acyclic Graph

Solve the All Ancestors of a Node in a Directed Acyclic Graph problem using graph traversal techniques like BFS, DFS, an…

Medium
2246

Longest Path With Different Adjacent Characters

Find the longest path in a tree where adjacent nodes have different characters using graph DFS and topological reasoning…

Hard
2328

Number of Increasing Paths in a Grid

Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…

Hard
2360

Longest Cycle in a Graph

The problem asks to find the longest cycle in a directed graph with specific edge constraints.

Hard
2392

Build a Matrix With Conditions

Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…

Hard
2603

Collect Coins in a Tree

The "Collect Coins in a Tree" problem requires traversing a tree to collect coins in the fewest steps while returning to…

Hard
3435

Frequencies of Shortest Supersequences

Compute all unique shortest common supersequences of given words using graph indegree tracking and topological ordering …

Hard
3530

Maximum Profit from Valid Topological Order in DAG

Solve the Maximum Profit from Valid Topological Order in DAG problem using graph indegree and topological sorting with d…

Hard
3620

Network Recovery Pathways

Find the maximum recovery cost of valid paths in a directed acyclic graph where some nodes are offline.

Hard

Related Patterns

Topological Sort LeetCode Problems: 28 Solutions