LeetCode 971: Flip Binary Tree To Match Preorder Traversal
A clear explanation of matching a binary tree preorder traversal by greedily flipping nodes.
79 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 checking whether every node in a binary tree has the same value.
A clear explanation of checking whether a binary tree is complete using level-order traversal.
A clear explanation of checking whether two binary trees are equivalent after swapping left and right children at any number of nodes.
A clear explanation of maintaining a complete binary tree inserter using level-order indexing.
A clear explanation of rearranging a binary search tree into an increasing right-only tree using inorder traversal.
A clear explanation of generating all full binary trees with n nodes using recursion and memoization.
A clear explanation of reconstructing a binary tree from preorder and postorder traversals using recursion and index ranges.
A clear explanation of Add One Row to Tree using tree traversal and careful subtree reconnection.
A clear explanation of counting uni-value subtrees using post-order DFS.
A clear explanation of inserting a value into a maximum binary tree by following the right spine.
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 balancing coins in a binary tree using postorder DFS and subtree coin balance.
A clear explanation of comparing two binary trees by collecting their leaf value sequences with DFS.
A clear explanation of finding the smallest subtree that contains all deepest nodes using bottom-up DFS.
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 postorder DFS solution for removing every binary tree subtree that does not contain a 1.
A clear explanation of inserting a value into a binary search tree using recursive and iterative traversal.
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 computing the maximum width of a binary tree using level-order traversal and complete-tree indices.
A clear explanation of formatting a binary tree into a 2D string matrix using tree height and recursive placement.
A clear explanation of constructing a maximum binary tree recursively using divide and conquer.
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 breadth-first search solution for computing the average value of nodes at each level of a binary tree.
A recursive tree traversal guide for merging two binary trees node by node.
A recursive guide for converting a binary tree into a preorder parenthesized string while preserving the one-to-one mapping between the tree and the string.
A clear explanation of finding the lowest common ancestor in a normal binary tree using recursive depth-first search.
A clear explanation of inverting a binary tree using recursive depth-first traversal.
Find the longest path in a binary tree where every node on the path has the same value using depth-first search.
A clear explanation of Subtree of Another Tree using recursive tree matching and DFS.
A clear explanation of Binary Tree Tilt using postorder DFS to compute subtree sums and accumulate tilt.
A clear explanation of finding the longest increasing or decreasing consecutive path in a binary tree using DFS.
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 parsing a parenthesized string recursively to construct a binary tree.
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 most frequent subtree sum in a binary tree using postorder DFS and a frequency map.
A clear explanation of finding the most frequent value or values in a binary search tree using inorder traversal.
Count downward paths in a binary tree whose values sum to targetSum using DFS and prefix sums.
Convert an N-ary tree into a binary tree and reconstruct it using the left-child right-sibling representation.
A clear explanation of the Sum of Left Leaves problem using depth-first traversal of a binary tree.
A clear explanation of grouping binary tree nodes by the round in which they become leaves using postorder DFS.
A clear explanation of House Robber III using tree dynamic programming with rob and skip states.
A clear explanation of verifying preorder serialization using slot counting without reconstructing the tree.
A clear explanation of Binary Tree Vertical Order Traversal using BFS with column indices.
A DFS solution for finding the longest parent-to-child path where each node value increases by exactly one.
A preorder DFS codec for converting a binary tree to a string and reconstructing the same tree from that string.
A clear explanation of the Binary Tree Paths problem using DFS backtracking to collect every root-to-leaf path.
A clear explanation of counting nodes in a complete binary tree faster than visiting every node.
A detailed guide to solving Same Tree with recursive DFS and structural comparison.
A detailed guide to solving Binary Tree Inorder Traversal with recursion and an iterative stack.
A clear explanation of returning the visible nodes from the right side of a binary tree using level-order traversal.
A clear explanation of flipping a binary tree upside down by rewiring pointers from the left spine.
Return the postorder traversal of a binary tree using recursion or an iterative stack-based approach.
Return the preorder traversal of a binary tree using recursion or an explicit stack.
Compute the sum of all numbers formed by root-to-leaf paths using depth-first search and decimal accumulation.
A clear explanation of finding the maximum path sum in a binary tree using bottom-up depth-first search.
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 flattening a binary tree into a linked list in preorder traversal order using recursive depth-first search.
A clear explanation of finding all root-to-leaf paths whose values add up to a target sum using depth-first search and backtracking.
A clear explanation of checking whether a binary tree has a root-to-leaf path whose values add up to a target sum.
A clear explanation of finding the minimum depth of a binary tree using breadth-first search.
A clear explanation of checking whether a binary tree is height-balanced using bottom-up depth-first search.
A clear explanation of returning binary tree levels from bottom to top using breadth-first search.
A clear explanation of rebuilding a binary tree from inorder and postorder traversals using recursion and an index map.
A clear explanation of rebuilding a binary tree from preorder and inorder traversals using recursion and an index map.
A clear explanation of finding the maximum depth of a binary tree using recursive depth-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.
A clear explanation of checking whether a binary tree is symmetric using mirror recursion.