DFS / Backtracking Pattern

Recursive exploration with undo for search spaces.

#Title
17Letter Combinations of a Phone Number
22Generate Parentheses
37Sudoku Solver
39Combination Sum
40Combination Sum II
46Permutations
47Permutations II
51N-Queens
52N-Queens-II
77Combinations
78Subsets
79Word Search
90Subsets II
93Restore IP Addresses
112Path Sum
113Path Sum II
126Word Ladder II
131Palindrome Partitioning
140Word Break II
199Binary Tree Right Side View
200Number of Islands
211Add and Search Word - Data structure design
212Word Search II
216Combination Sum III
236Lowest Common Ancestor of a Binary Tree
247Strobogrammatic Number II
250Count Univalue Subtrees
254Factor Combinations
257Binary Tree Paths
267Palindrome Permutation II
269Alien Dictionary
282Expression Add Operators
291Word Pattern II
297Serialize and Deserialize Binary Tree
301Remove Invalid Parentheses
307Range Sum Query - Mutable
308Range Sum Query 2D - Mutable
320Generalized Abbreviation
329Longest Increasing Path in a Matrix
339Nested List Weight Sum
351Android Unlock Patterns
357Count Numbers with Unique Digits
364Nested List Weight Sum II
366Find Leaves of Binary Tree
417Pacific Atlantic Water Flow
425Word Squares
440K-th Smallest in Lexicographical Order
464Can I Win
488Zuma Game
491Increasing Subsequences
508Most Frequent Subtree Sum
513Find Bottom Left Tree Value
515Find Largest Value in Each Tree Row
526Beautiful Arrangement
559Max Consecutive Ones
582Kill Process
638Shopping Offers
652Find Duplicate Subtrees
662Maximum Width of Binary Tree
676Implement Magic Dictionary
67924 Game
690Employee Importance
691Stickers to Spell Word
694Number of Distinct Islands
695Max Area of Island
698Partition to K Equal Sum Subsets
711Number of Distinct Islands II
733Max Area of Island
749Contain Virus
753Cracking the Safe
756Pyramid Transition Matrix
784Letter Case Permutation
785Is Graph Bipartite?
797All Paths From Source to Target
802Find Eventual Safe States
814Binary Tree Pruning
827Making A Large Island
834Sum of Distances in Tree
841Keys and Rooms
851Loud and Rich
865Smallest Subtree with all the Deepest Nodes
889Construct Binary Tree from Preorder and Postorder Traversal
897Increasing Order Search Tree
934Shortest Bridge
938Range Sum of BST
951Flip Equivalent Binary Trees
965Univalued Binary Tree
968Binary Tree Cameras
971Flip Binary Tree To Match Preorder Traversal
979Distribute Coins in Binary Tree
987Vertical Order Traversal of a Binary Tree
988Smallest String Starting From Leaf
993Cousins in Binary Tree
996Number of Squareful Arrays
1020Number of Enclaves
1026Maximum Difference Between Node and Ancestor
1028Recover a Tree From Preorder Traversal
1038Binary Search Tree to Greater Sum Tree
1059All Paths from Source Lead to Destination
1079Letter Tile Possibilities
1080Insufficient Nodes in Root to Leaf Paths
1087Brace Expansion
1096Brace Expansion II
1102Path With Maximum Minimum Value
1120Maximum Average Subtree
1123Lowest Common Ancestor of Deepest Leaves
1145Binary Tree Coloring Game
1161Maximum Level Sum of a Binary Tree
1192Critical Connections in a Network
1219Path with Maximum Gold
1240Tiling a Rectangle with the Fewest Squares
1254Number of Closed Islands
1255Maximum Score Words Formed by Letters
1261Find Elements in a Contaminated Binary Tree
1273Delete Tree Nodes
1307Verbal Arithmetic Puzzle
1315Sum of Nodes with Even-Valued Grandparent
1319Number of Operations to Make Network Connected
1325Delete Leaves With a Given Value
1339Maximum Product of Splitted Binary Tree
1361Validate Binary Tree Nodes
1372Longest ZigZag Path in a Binary Tree
1373Maximum Sum BST in Binary Tree
1376Time Needed to Inform All Employees
1377Frog Position After T Seconds
1382Balance a Binary Search Tree
1391Check if There is a Valid Path in a Grid
1430Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree
1443Minimum Time to Collect All Apples in a Tree
1448Count Good Nodes in Binary Tree
1457Pseudo-Palindromic Paths in a Binary Tree
1466Reorder Routes to Make All Paths Lead to the City Zero
1469Find All The Lonely Nodes
1485Clone Binary Tree With Random Pointer
1490Clone N-ary Tree
1516Move Sub-Tree of N-Ary Tree
1519Number of Nodes in the Sub-Tree With the Same Label
1522Diameter of N-Ary Tree
1530Number of Good Leaf Nodes Pairs
1568Minimum Number of Days to Disconnect Island
1593Split a String Into the Max Number of Unique Substrings
1601Maximum Number of Achievable Transfer Requests
1617Count Subtrees With Max Distance Between Cities
1631Path With Minimum Effort
1644Lowest Common Ancestor of a Binary Tree II
1659Maximize Grid Happiness
1676Lowest Common Ancestor of a Binary Tree IV
1681Minimum Incompatibility
1718Construct the Lexicographically Largest Valid Sequence
1723Find Minimum Time to Finish All Jobs
1740Find Distance in a Binary Tree
1766Tree of Coprimes
1778Shortest Path in a Hidden Grid
1810Minimum Path Cost in a Hidden Grid
1849Splitting a String Into Descending Consecutive Values
1858Longest Word With All Prefixes
1905Count Sub Islands
1916Count Ways to Build Rooms in an Ant Colony
1931Painting a Grid With Three Different Colors
1938Maximum Genetic Difference Query
1948Delete Duplicate Folders in System
1973Count Nodes Equal to Sum of Descendants
1999Smallest Greater Multiple Made of Two Digits
2003Smallest Missing Genetic Value in Each Subtree
2014Longest Subsequence Repeated k Times
2049Count Nodes With the Highest Score
2056Number of Valid Move Combinations On Chessboard
2065Maximum Path Quality of a Graph
2092Find All People With Secret
2094Finding 3-Digit Even Numbers
2096Step-By-Step Directions From a Binary Tree Node to Another
2184Number of Ways to Build Sturdy Brick Wall
2192All Ancestors of a Node in a Directed Acyclic Graph
2246Longest Path With Different Adjacent Characters
2265Count Nodes Equal to Average of Subtree
2307Check for Contradictions in Equations
2322Minimum Score After Removals on a Tree
2331Evaluate Boolean Binary Tree
2359Find Closest Node to Given Two Nodes
2360Longest Cycle in a Graph
2378Choose Edges to Maximize Score in a Tree
2385Amount of Time for Binary Tree to Be Infected
2440Create Components With Same Value
2443Sum of Number and Its Reverse
2445Number of Nodes With Value One
2458Height of Binary Tree After Subtree Removal Queries
2467Most Profitable Path in a Tree
2476Closest Nodes Queries in a Binary Search Tree
2477Minimum Fuel Cost to Report to the Capital
2479Maximum XOR of Two Non-Overlapping Subtrees
2493Divide Nodes Into the Maximum Number of Groups
2538Difference Between Maximum and Minimum Price Sum
2556Disconnect Path in a Binary Matrix by at Most One Flip
2581Count Number of Possible Root Nodes
2625Flatten Deeply Nested Array
2628JSON Deep Equal
2633Convert Object to JSON String
2646Minimize the Total Price of the Trips
2649Nested Array Generator
2658Maximum Number of Fish in a Grid
2664The Knight’s Tour
2675Array of Objects to Matrix
2698Find the Punishment Number of an Integer
2700Differences Between Two Objects
2705Compact Object
2741Special Permutations
2755Deep Merge of Two Objects
2773Height of Special Binary Tree
2775Undefined to Null
2791Count Paths That Can Form a Palindrome in a Tree
2823Deep Object Filter
2850Minimum Moves to Spread Stones Over Grid
2858Minimum Edge Reversals So Every Node Is Reachable
2867Count Valid Paths in a Tree
2920Maximum Points After Collecting Coins From All Nodes
2925Maximum Score After Applying Operations on a Tree
2959Number of Possible Sets of Closing Branches
2973Find Number of Coins to Place in Tree Nodes
3004Maximum Subtree of the Same Color
3067Count Pairs of Connectable Servers in a Weighted Tree Network
3203Find Minimum Diameter After Merging Two Trees
3211Generate Binary Strings Without Adjacent Zeros
3235Check if the Rectangle Corner Is Reachable
3241Time Taken to Mark All Nodes
3249Count the Number of Good Nodes
3313Find the Last Marked Nodes in Tree
3319K-th Largest Perfect Subtree Size in Binary Tree
3327Check if DFS Strings Are Palindromes
3331Find Subtree Sizes After Changes
3367Maximize Sum of Weights after Edge Removals
3372Maximize the Number of Target Nodes After Connecting Trees I
3425Longest Special Path
3437Permutations III
3486Longest Special Path II
3515Shortest Path in a Weighted Tree
3544Subtree Inversion Sum
3553Minimum Weighted Subgraph With the Required Paths II
3559Number of Ways to Assign Edge Weights II
3562Maximum Profit from Trading Stocks with Discounts
3565Sequential Grid Path Cover
3575Maximum Good Subtree Score
3585Find Weighted Median Node in Tree
3590Kth Smallest Path XOR Sum
3593Minimum Increments to Equalize Leaf Paths
3607Power Grid Maintenance
3669Balanced K-Factor Decomposition
3715Sum of Perfect Square Ancestors
3786Total Sum of Interaction Cost in Tree Groups
3841Palindromic Path Queries in a Tree
3879Maximum Distinct Path Sum in a Binary Tree
3910Count Connected Subgraphs with Even Node Sum
3949Subtree Inversion Sum II
3955Valid Binary Strings With Cost Limit
3965Finish Time of Tasks I
3967Finish Time of Tasks II
3973Distinct Gate Paths to LCA