LeetCode 971: Flip Binary Tree To Match Preorder Traversal
A clear explanation of matching a binary tree preorder traversal by greedily flipping nodes.
51 notes
A clear explanation of matching a binary tree preorder traversal by greedily flipping nodes.
A clear explanation of placing the minimum number of cameras in a binary tree using postorder DFS.
A clear explanation of generating all n-digit numbers whose adjacent digits differ by k.
A clear explanation of checking whether every node in a binary tree has the same value.
A clear explanation of the Split Array into Fibonacci Sequence problem using backtracking, leading-zero checks, and 32-bit integer limits.
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 the Making A Large Island problem using connected component labeling and island size lookup.
A clear explanation of minimizing malware spread by analyzing connected components with Union Find.
A clear explanation of checking whether two binary tree nodes are cousins using BFS with parent tracking.
A clear explanation of finding the lexicographically smallest leaf-to-root string in a binary tree using DFS.
A clear explanation of vertical tree traversal using coordinates, DFS, sorting, and column grouping.
A clear explanation of counting all paths from start to end that visit every non-obstacle square exactly once using backtracking.
A clear explanation of balancing coins in a binary tree using postorder DFS and subtree coin balance.
A clear explanation of solving Most Stones Removed with Same Row or Column using connected components and union-find.
A clear explanation of solving Range Sum of BST using DFS with binary search tree pruning.
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.
Simulate virus containment by repeatedly quarantining the most dangerous infected region and spreading the remaining regions.
Find the nearest leaf to a target node by converting the tree into an undirected graph and running breadth-first search.
Recolor the connected component containing the starting pixel using depth-first search.
A clear explanation of finding the second minimum value in a special binary tree using DFS.
A clear explanation of trimming a BST so that all remaining node values lie inside a given inclusive range.
A clear explanation of computing all root-to-leaf path sums from a compact three-digit binary tree encoding.
A clear explanation of checking whether a binary tree can be split into two equal-sum trees by removing one edge.
A clear explanation of formatting a binary tree into a 2D string matrix using tree height and recursive placement.
A clear explanation of finding whether two different nodes in a binary search tree sum to a target value.
A clear explanation of finding duplicate binary tree subtrees using postorder traversal, serialization, and a hash map.
A clear explanation of Subtree of Another Tree using recursive tree matching and DFS.
A clear explanation of Array Nesting using cycle detection over a permutation.
A clear explanation of Binary Tree Tilt using postorder DFS to compute subtree sums and accumulate tilt.
A clear explanation of Maximum Depth of N-ary Tree using recursive depth-first search.
A clear explanation of finding the longest increasing or decreasing consecutive path in a binary tree using DFS.
A clear explanation of counting connected components in an undirected graph represented by an adjacency matrix.
A clear explanation of collecting the boundary of a binary tree using separate left boundary, leaves, and right boundary traversals.
A clear explanation of finding the longest path between any two nodes in a binary tree using DFS height computation.
A clear explanation of converting a BST into a greater tree using reverse inorder traversal and a running sum.
A clear explanation of finding the minimum difference between two BST node values using inorder traversal.
A clear explanation of updating a Minesweeper board using DFS flood fill and adjacent mine counting.
A clear explanation of generating numbers from 1 to n in lexicographical order using an iterative DFS-style traversal.
A clear explanation of Nested List Weight Sum using depth-first search over a nested structure.
A detailed guide to solving Same Tree with recursive DFS and structural comparison.
A detailed guide to solving Recover Binary Search Tree with inorder traversal and two misplaced nodes.
A detailed guide to solving Validate Binary Search Tree with recursive lower and upper bounds.
A detailed guide to solving Binary Tree Inorder Traversal with recursion and an iterative stack.
A detailed guide to solving Word Search with depth-first search and backtracking on a grid.
A clear explanation of counting connected groups of land cells in a grid using DFS or BFS.
A clear explanation of returning the visible nodes from the right side of a binary tree using level-order traversal.
A detailed explanation of generating all well-formed parentheses strings using backtracking.
A detailed explanation of generating all possible phone keypad letter combinations using backtracking.