LeetCode 886: Possible Bipartition
A clear explanation of checking whether people can be split into two groups using graph coloring and bipartite graph detection.
41 notes
A clear explanation of checking whether people can be split into two groups using graph coloring and bipartite graph detection.
A clear explanation of Add One Row to Tree using tree traversal and careful subtree reconnection.
A clear explanation of finding the minimum moves to collect all keys in a grid using BFS with key bitmasks.
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 dynamic programming solution for finding the shortest instruction sequence that drives a race car to the target position.
A BFS solution for finding the minimum number of buses needed to travel from a source stop to a target stop.
A clear explanation of checking whether an undirected graph can be split into two independent sets using graph coloring.
A clear explanation of solving the 2 x 3 sliding puzzle using breadth-first search over board states.
A clear explanation of solving Open the Lock using breadth-first search over lock states.
Find the largest connected island area in a binary grid using depth-first search.
Compute the total importance of an employee and all direct and indirect subordinates using a hash map and depth-first search.
A clear graph traversal solution for finding all processes terminated when killing a target process.
A clear explanation of finding the maximum value at every depth of a binary tree using level-order traversal.
A clear explanation of finding the leftmost value in the deepest row of a binary tree using level-order traversal.
A clear explanation of finding the shortest rolling distance in a maze using Dijkstra’s algorithm.
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.
Find the minimum number of valid one-character gene mutations using breadth-first search.
Traverse an N-ary tree level by level using breadth-first search.
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 computing inverse depth weighted sum using level-order traversal.
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 Binary Tree Vertical Order Traversal using BFS with column indices.
A clear explanation of Minimum Height Trees using leaf trimming to find the center of a tree.
A clear explanation of Remove Invalid Parentheses using BFS to guarantee the minimum number of removals.
A clear explanation of the Alien Dictionary problem using graph construction and topological sorting.
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.
Create a deep copy of a connected undirected graph using DFS and a hash map from original nodes to cloned nodes.
Capture surrounded O regions by marking border-connected O cells first, then flipping the remaining O cells.
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.
A clear explanation of connecting next pointers in any binary tree using constant extra space.
A clear explanation of connecting next pointers in a perfect binary tree using constant extra space.
A clear explanation of finding the minimum depth of a binary tree using breadth-first search.
A clear explanation of returning binary tree levels from bottom to top using breadth-first search.
A clear explanation of zigzag level order traversal using breadth-first search and alternating level direction.
A clear explanation of binary tree level order traversal using breadth-first search and a queue.