Depth-First Search Interview Questions

Deep traversal, backtracking setups, and components.

85 problems

#Title
112Path Sum
113Path Sum II
199Binary Tree Right Side View
200Number of Islands
236Lowest Common Ancestor of a Binary Tree
247Strobogrammatic Number II
250Count Univalue Subtrees
257Binary Tree Paths
282Expression Add Operators
301Remove Invalid Parentheses
329Longest Increasing Path in a Matrix
339Nested List Weight Sum
364Nested List Weight Sum II
366Find Leaves of Binary Tree
417Pacific Atlantic Water Flow
440K-th Smallest in Lexicographical Order
464Can I Win
515Find Largest Value in Each Tree Row
547Friend Circles
582Kill Process
638Shopping Offers
690Employee Importance
694Number of Distinct Islands
695Max Area of Island
711Number of Distinct Islands II
733Max Area of Island
749Contain Virus
753Cracking the Safe
756Pyramid Transition Matrix
785Is Graph Bipartite?
797All Paths From Source to Target
802Find Eventual Safe States
827Making A Large Island
834Sum of Distances in Tree
841Keys and Rooms
851Loud and Rich
1020Number of Enclaves
1059All Paths from Source Lead to Destination
1192Critical Connections in a Network
1202Smallest String With Swaps
1254Number of Closed Islands
1273Delete Tree Nodes
1315Sum of Nodes with Even-Valued Grandparent
1319Number of Operations to Make Network Connected
1367Linked List in Binary Tree
1372Longest ZigZag Path in a Binary Tree
1376Time Needed to Inform All Employees
1377Frog Position After T Seconds
1391Check if There is a Valid Path in a Grid
1466Reorder Routes to Make All Paths Lead to the City Zero
1485Clone Binary Tree With Random Pointer
1644Lowest Common Ancestor of a Binary Tree II
1676Lowest Common Ancestor of a Binary Tree IV
1722Minimize Hamming Distance After Swap Operations
1740Find Distance in a Binary Tree
1766Tree of Coprimes
1905Count Sub Islands
1973Count Nodes Equal to Sum of Descendants
2049Count Nodes With the Highest Score
2065Maximum Path Quality of a Graph
2192All Ancestors of a Node in a Directed Acyclic Graph
2246Longest Path With Different Adjacent Characters
2265Count Nodes Equal to Average of Subtree
2322Minimum Score After Removals on a Tree
2331Evaluate Boolean Binary Tree
2385Amount of Time for Binary Tree to Be Infected
2445Number of Nodes With Value One
2458Height of Binary Tree After Subtree Removal Queries
2467Most Profitable Path in a Tree
2477Minimum Fuel Cost to Report to the Capital
2581Count Number of Possible Root Nodes
2773Height of Special Binary Tree
2791Count Paths That Can Form a Palindrome in a Tree
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
3249Count the Number of Good Nodes
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
3590Kth Smallest Path XOR Sum
3593Minimum Increments to Equalize Leaf Paths
3607Power Grid Maintenance