LeetCode 959: Regions Cut By Slashes
A clear explanation of counting regions formed by slashes using union find over four triangles per cell.
63 notes
A clear explanation of counting regions formed by slashes using union find over four triangles per cell.
A clear explanation of the Shortest Path Visiting All Nodes problem using multi-source BFS and bitmask state compression.
A clear explanation of the Keys and Rooms problem using graph traversal from room 0.
A clear explanation of the Similar String Groups problem using graph connectivity and union-find.
A clear explanation of the Sum of Distances in Tree problem using tree DP, subtree sizes, and rerooting.
A clear explanation of minimizing malware spread by analyzing connected components with Union Find.
A clear explanation of Cat and Mouse using game states, reverse BFS, and topological propagation.
A clear explanation of Snakes and Ladders using breadth-first search over board squares.
A clear explanation of checking whether people can be split into two groups using graph coloring and bipartite graph detection.
A clear explanation of counting reachable original and subdivided nodes using Dijkstra's shortest path algorithm.
A clear explanation of identifying the town judge using trust indegree and outdegree counts.
A clear explanation of counting unique permutations where every adjacent pair sums to a perfect square using backtracking.
A clear explanation of finding the minimum time for all oranges to rot using multi-source BFS.
A clear explanation of checking equality and inequality constraints using union-find.
A clear explanation of finding all binary tree nodes at distance k from a target node by treating the tree as an undirected graph.
A clear explanation of finding the minimum number of swaps needed to transform one anagram string into another using BFS.
A clear explanation of Loud and Rich using graph traversal, DFS, and memoization.
A clear explanation of solving Most Stones Removed with Same Row or Column using connected components and union-find.
A clear explanation of solving Find the Shortest Superstring using pairwise overlaps and bitmask dynamic programming.
A clear explanation of solving Stamping The Sequence using reverse simulation and BFS-style processing.
A clear explanation of solving Knight Dialer using dynamic programming over the phone keypad graph.
A clear explanation of solving Shortest Bridge using DFS to mark one island and BFS to expand toward the other island.
A clear explanation of solving Minimize Malware Spread II by removing each infected node and simulating the final malware spread.
A BFS solution for finding the minimum number of buses needed to travel from a source stop to a target stop.
A graph traversal solution for finding all nodes that cannot reach a directed cycle.
A clear explanation of finding every path from node 0 to node n - 1 in a directed acyclic graph using DFS and backtracking.
A clear explanation of finding the cheapest flight route with at most k stops using bounded Bellman-Ford relaxation.
A clear explanation of checking whether an undirected graph can be split into two independent sets using graph coloring.
A clear explanation of finding the minimum time to reach the bottom-right cell using a priority queue and minimax path reasoning.
A clear explanation of solving the 2 x 3 sliding puzzle using breadth-first search over board states.
A clear explanation of Cracking the Safe using a de Bruijn sequence and depth-first search over password states.
A clear explanation of solving Open the Lock using breadth-first search over lock states.
A clear explanation of merging accounts that share emails using union find and sorted email groups.
Find the time needed for a signal to reach all nodes in a directed weighted graph using Dijkstra's algorithm.
Find the nearest leaf to a target node by converting the tree into an undirected graph and running breadth-first search.
Check sentence similarity with transitive word relationships using union-find.
Find the directed edge to remove so a graph becomes a rooted tree again, handling both cycles and nodes with two parents.
Find the extra edge in an undirected graph that creates a cycle using Union-Find.
A clear graph traversal solution for finding all processes terminated when killing a target process.
A clear explanation of Maximum Vacation Days using dynamic programming over weeks and cities.
A clear explanation of counting connected components in an undirected graph represented by an adjacency matrix.
A clear explanation of finding the shortest rolling distance in a maze using Dijkstra’s algorithm.
A clear explanation of finding the shortest rolling-ball path to the hole using Dijkstra with lexicographic tie-breaking.
A clear explanation of deciding whether a rolling ball can stop at the destination using BFS or DFS over stopping cells.
Check whether nums is the unique shortest supersequence of given subsequences using topological sorting.
A clear explanation of finding cells that can flow to both oceans using reverse graph traversal from the borders.
A clear explanation of trapping rain water in a 2D elevation map using a min heap and boundary expansion.
A clear explanation of solving division equations using graph traversal and weighted edges.
A clear explanation of Reconstruct Itinerary using a directed graph and Hierholzer's algorithm.
A clear explanation of counting connected components using Union-Find and graph traversal.
A clear explanation of Shortest Distance from All Buildings using BFS from each building with distance and reach accumulation.
A clear explanation of Minimum Height Trees using leaf trimming to find the center of a tree.
A clear explanation of Number of Islands II using Union-Find to dynamically merge connected land cells.
A multi-source BFS solution for filling each empty room with its shortest distance to the nearest gate.
A two-pass solution for finding a celebrity using the knows API with O(n) calls and O(1) extra space.
A clear explanation of the Alien Dictionary problem using graph construction and topological sorting.
A clear explanation of the Graph Valid Tree problem using Union Find to detect cycles and verify connectivity.
A clear explanation of finding a valid course ordering using topological sorting and cycle detection.
A clear explanation of detecting cycles in a prerequisite graph using topological sorting and DFS.
A clear explanation of counting connected groups of land cells in a grid using DFS or BFS.
Create a deep copy of a connected undirected graph using DFS and a hash map from original nodes to cloned nodes.
Use breadth-first search to find the shortest transformation sequence length between two words.
Find all shortest word transformation sequences using BFS to build shortest-path parents, then backtracking to reconstruct every answer.