Learn how to list all “eventual safe” nodes in a directed graph. We use DFS with path-tracking to spot cycles…
Browsing: Expert
We flip the graph, run Kahn’s topological BFS, and list every node guaranteed to avoid cycles. Includes clear intuition, step-by-step…
Learn how to count the number of distinct islands shape in a binary grid using DFS and shape hashing. Clear…
Learn how to find all shortest paths (Word Ladder II) from one word to another by changing one letter at…
Learn how to solve the Word Ladder problem by building a BFS over words, changing one letter at a time.…
Learn how to count the number of land cells in a grid that cannot reach the border by water. This…
Learn how to solve the Surrounded Regions problem by marking all ‘O’s connected to the border via DFS, then flipping…
Learn how to solve the “01 Matrix” problem (LeetCode 542) by using a multi-source breadth-first search. We walk through the…
Learn how to solve the “Rotting Oranges” problem from LeetCode using a breadth-first search (BFS) approach. We walk through the…