LeetCode 964: Least Operators to Express Number
A clear explanation of expressing a target using the fewest operators with repeated uses of x.
94 notes
A clear explanation of expressing a target using the fewest operators with repeated uses of x.
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 rearranging a binary search tree into an increasing right-only tree using inorder traversal.
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 counting uni-value subtrees using post-order DFS.
A clear explanation of counting strobogrammatic numbers in a string range using recursive generation and range filtering.
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 clear explanation of Loud and Rich using graph traversal, DFS, and memoization.
A postorder DFS solution for removing every binary tree subtree that does not contain a 1.
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 checking whether an undirected graph can be split into two independent sets using graph coloring.
A clear explanation of generating all strings formed by independently changing each letter to lowercase or uppercase.
A clear explanation of finding the minimum difference between any two nodes in a BST using inorder traversal.
A clear explanation of solving Pyramid Transition Matrix using backtracking and memoization over pyramid rows.
A clear explanation of Cracking the Safe using a de Bruijn sequence and depth-first search over password states.
A clear explanation of counting distinct island shapes under rotation and reflection using normalization and geometric transformations.
Find the largest connected island area in a binary grid using depth-first search.
Count unique island shapes in a binary grid using DFS and relative coordinates.
Compute the total importance of an employee and all direct and indirect subordinates using a hash map and depth-first search.
A DFS and memoization solution for finding the minimum cost to satisfy item needs using individual prices and reusable special offers.
A recursive tree traversal guide for merging two binary trees node by node.
A clear explanation of finding the lowest common ancestor in a normal binary tree using recursive depth-first search.
A clear explanation of finding the lowest common ancestor in a binary search tree using BST ordering properties.
A clear explanation of finding the kth smallest value in a binary search tree using inorder traversal.
A clear explanation of inverting a binary tree using recursive depth-first traversal.
A clear explanation of Permutations using depth-first search and backtracking.
Search for a target value in a binary search tree and return the subtree rooted at the matching node.
Find the longest path in a binary tree where every node on the path has the same value using depth-first search.
A clear DFS solution for returning the postorder traversal of an N-ary tree.
A clear DFS solution for returning the preorder traversal of an N-ary tree.
A clear graph traversal solution for finding all processes terminated when killing a target process.
A clear explanation of finding the minimum steps to spell a key on a circular ring using dynamic programming and memoized DFS.
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.
A clear explanation of deciding whether a rolling ball can stop at the destination using BFS or DFS over stopping cells.
A clear explanation of cleaning an unknown grid using DFS, relative coordinates, and physical backtracking.
A clear explanation of solving Zuma Game with DFS, memoization, and chain-removal simulation.
A clear explanation of deciding whether matchsticks can form a square using backtracking, sorting, and pruning.
A clear explanation of minimizing debt-settlement transactions using net balances, backtracking, and memoization-style pruning.
Delete a node from a binary search tree while preserving the BST property using recursive search and inorder successor replacement.
Serialize a binary search tree compactly with preorder traversal and rebuild it using BST value bounds.
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.
Flatten a multilevel doubly linked list in-place using depth-first traversal and pointer splicing.
Serialize an N-ary tree into a string and reconstruct the same tree using preorder traversal with child counts.
Convert a BST into a sorted circular doubly linked list in-place using inorder traversal.
A clear explanation of finding cells that can flow to both oceans using reverse graph traversal from the borders.
A clear explanation of the Sum of Left Leaves problem using depth-first traversal of a binary tree.
A clear explanation of the Frog Jump problem using dynamic programming with reachable jump sizes.
A clear explanation of solving division equations using graph traversal and weighted edges.
A clear explanation of grouping binary tree nodes by the round in which they become leaves using postorder DFS.
A clear explanation of computing inverse depth weighted sum using level-order traversal.
A clear explanation of Android Unlock Patterns using backtracking, a jump table, and symmetry optimization.
A clear explanation of Flatten Nested List Iterator using lazy stack-based flattening.
A clear explanation of House Robber III using tree dynamic programming with rob and skip states.
A clear explanation of Largest BST Subtree using postorder traversal and subtree state propagation.
A clear explanation of Reconstruct Itinerary using a directed graph and Hierholzer's algorithm.
A clear explanation of Longest Increasing Path in a Matrix using DFS with memoization.
A clear explanation of counting connected components using Union-Find and graph traversal.
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 backtracking solution for inserting operators into a numeric string so the expression evaluates to a target value.
A clear explanation of the Closest Binary Search Tree Value problem using the BST property to walk toward the target.
A clear explanation of the Graph Valid Tree problem using Union Find to detect cycles and verify connectivity.
A clear explanation of the Binary Tree Paths problem using DFS backtracking to collect every root-to-leaf path.
A clear explanation of the Factor Combinations problem using DFS backtracking with non-decreasing factors.
A clear explanation of finding k distinct numbers from 1 to 9 that sum to n using backtracking.
A clear explanation of finding multiple words in a character board using a Trie and DFS backtracking.
A clear explanation of designing a word dictionary with addWord and wildcard search using a Trie and DFS.
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 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.
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.
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 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 checking whether a binary tree is height-balanced using bottom-up depth-first search.
A clear explanation of converting a sorted linked list into a height-balanced binary search tree using slow and fast pointers.
A clear explanation of building a height-balanced binary search tree from a sorted array using divide and conquer.
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 checking whether a binary tree is symmetric using mirror recursion.
A clear guide to solving N-Queens II by counting valid queen placements with backtracking.
A clear guide to solving N-Queens with backtracking, row-by-row placement, and constant-time conflict checks.