Learn how to test if an undirected graph is bipartite by coloring it with two colors. Simple DFS idea, commented…
Browsing: Graph
Learn how to count the number of distinct islands shape in a binary grid using DFS and shape hashing. Clear…
Learn how to count the number of islands (leetcode 200) in a 2-D grid using both Breadth-First Search (BFS) and…
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 detect a cycle in an undirected graph with a depth-first search (DFS) approach. This beginner-friendly guide walks…
Learn how to detect a cycle in an undirected graph with a breadth-first search (BFS) approach. This beginner-friendly guide walks…