← back

Depth-First Search

257 questions · 0 seen

All Depth-First Search problems

Problems

79 Word Search
94 Binary Tree Inorder Traversal
98 Validate Binary Search Tree
99 Recover Binary Search Tree
100 Same Tree
101 Symmetric Tree
104 Maximum Depth of Binary Tree
110 Balanced Binary Tree
111 Minimum Depth of Binary Tree
112 Path Sum
113 Path Sum II
114 Flatten Binary Tree to Linked List
116 Populating Next Right Pointers in Each Node
117 Populating Next Right Pointers in Each Node II
124 Binary Tree Maximum Path Sum
129 Sum Root to Leaf Numbers
130 Surrounded Regions
133 Clone Graph
144 Binary Tree Preorder Traversal
145 Binary Tree Postorder Traversal
199 Binary Tree Right Side View
200 Number of Islands
207 Course Schedule
210 Course Schedule II
211 Design Add and Search Words Data Structure
226 Invert Binary Tree
230 Kth Smallest Element in a BST
235 Lowest Common Ancestor of a Binary Search Tree
236 Lowest Common Ancestor of a Binary Tree
257 Binary Tree Paths
297 Serialize and Deserialize Binary Tree
310 Minimum Height Trees
329 Longest Increasing Path in a Matrix
332 Reconstruct Itinerary
337 House Robber III
341 Flatten Nested List Iterator
365 Water and Jug Problem
385 Mini Parser
386 Lexicographical Numbers
388 Longest Absolute File Path
399 Evaluate Division
404 Sum of Left Leaves
417 Pacific Atlantic Water Flow
419 Battleships in a Board
430 Flatten a Multilevel Doubly Linked List
437 Path Sum III
449 Serialize and Deserialize BST
463 Island Perimeter
472 Concatenated Words
501 Find Mode in Binary Search Tree
508 Most Frequent Subtree Sum
513 Find Bottom Left Tree Value
514 Freedom Trail
515 Find Largest Value in Each Tree Row
529 Minesweeper
530 Minimum Absolute Difference in BST
538 Convert BST to Greater Tree
543 Diameter of Binary Tree
547 Number of Provinces
559 Maximum Depth of N-ary Tree
563 Binary Tree Tilt
565 Array Nesting
572 Subtree of Another Tree
589 N-ary Tree Preorder Traversal
590 N-ary Tree Postorder Traversal
606 Construct String from Binary Tree
617 Merge Two Binary Trees
623 Add One Row to Tree
637 Average of Levels in Binary Tree
652 Find Duplicate Subtrees
653 Two Sum IV - Input is a BST
655 Print Binary Tree
662 Maximum Width of Binary Tree
669 Trim a Binary Search Tree
671 Second Minimum Node In a Binary Tree
672 Bulb Switcher II
676 Implement Magic Dictionary
684 Redundant Connection
685 Redundant Connection II
687 Longest Univalue Path
690 Employee Importance
695 Max Area of Island
721 Accounts Merge
733 Flood Fill
743 Network Delay Time
749 Contain Virus
753 Cracking the Safe
765 Couples Holding Hands
778 Swim in Rising Water
783 Minimum Distance Between BST Nodes
785 Is Graph Bipartite?
787 Cheapest Flights Within K Stops
797 All Paths From Source to Target
802 Find Eventual Safe States
814 Binary Tree Pruning
827 Making A Large Island
834 Sum of Distances in Tree
839 Similar String Groups
841 Keys and Rooms
851 Loud and Rich
863 All Nodes Distance K in Binary Tree
865 Smallest Subtree with all the Deepest Nodes
872 Leaf-Similar Trees
886 Possible Bipartition
897 Increasing Order Search Tree
924 Minimize Malware Spread
928 Minimize Malware Spread II
934 Shortest Bridge
938 Range Sum of BST
947 Most Stones Removed with Same Row or Column
951 Flip Equivalent Binary Trees
959 Regions Cut By Slashes
965 Univalued Binary Tree
968 Binary Tree Cameras
971 Flip Binary Tree To Match Preorder Traversal
979 Distribute Coins in Binary Tree
987 Vertical Order Traversal of a Binary Tree
988 Smallest String Starting From Leaf
993 Cousins in Binary Tree
1020 Number of Enclaves
1022 Sum of Root To Leaf Binary Numbers
1026 Maximum Difference Between Node and Ancestor
1028 Recover a Tree From Preorder Traversal
1034 Coloring A Border
1036 Escape a Large Maze
1038 Binary Search Tree to Greater Sum Tree
1042 Flower Planting With No Adjacent
1080 Insufficient Nodes in Root to Leaf Paths
1110 Delete Nodes And Return Forest
1123 Lowest Common Ancestor of Deepest Leaves
1145 Binary Tree Coloring Game
1161 Maximum Level Sum of a Binary Tree
1192 Critical Connections in a Network
1202 Smallest String With Swaps
1203 Sort Items by Groups Respecting Dependencies
1233 Remove Sub-Folders from the Filesystem
1254 Number of Closed Islands
1261 Find Elements in a Contaminated Binary Tree
1267 Count Servers that Communicate
1302 Deepest Leaves Sum
1305 All Elements in Two Binary Search Trees
1306 Jump Game III
1315 Sum of Nodes with Even-Valued Grandparent
1319 Number of Operations to Make Network Connected
1325 Delete Leaves With a Given Value
1339 Maximum Product of Splitted Binary Tree
1361 Validate Binary Tree Nodes
1367 Linked List in Binary Tree
1372 Longest ZigZag Path in a Binary Tree
1373 Maximum Sum BST in Binary Tree
1376 Time Needed to Inform All Employees
1377 Frog Position After T Seconds
1379 Find a Corresponding Node of a Binary Tree in a Clone of That Tree
1382 Balance a Binary Search Tree
1391 Check if There is a Valid Path in a Grid
1443 Minimum Time to Collect All Apples in a Tree
1448 Count Good Nodes in Binary Tree
1457 Pseudo-Palindromic Paths in a Binary Tree
1462 Course Schedule IV
1466 Reorder Routes to Make All Paths Lead to the City Zero
1483 Kth Ancestor of a Tree Node
1519 Number of Nodes in the Sub-Tree With the Same Label (PRO)
1530 Number of Good Leaf Nodes Pairs (PRO)
1559 Detect Cycles in 2D Grid
1568 Minimum Number of Days to Disconnect Island
1600 Throne Inheritance
1625 Lexicographically Smallest String After Applying Operations
1631 Path With Minimum Effort
1722 Minimize Hamming Distance After Swap Operations
1743 Restore the Array From Adjacent Pairs
1766 Tree of Coprimes
1905 Count Sub Islands
1916 Count Ways to Build Rooms in an Ant Colony
1932 Merge BSTs to Create Single BST
1938 Maximum Genetic Difference Query (PRO)
1970 Last Day Where You Can Still Cross (PRO)
1971 Find if Path Exists in Graph
1992 Find All Groups of Farmland (PRO)
1993 Operations on Tree
2003 Smallest Missing Genetic Value in Each Subtree
2049 Count Nodes With the Highest Score
2092 Find All People With Secret
2096 Step-By-Step Directions From a Binary Tree Node to Another
2097 Valid Arrangement of Pairs
2101 Detonate the Maximum Bombs
2127 Maximum Employees to Be Invited to a Meeting
2192 All Ancestors of a Node in a Directed Acyclic Graph
2246 Longest Path With Different Adjacent Characters
2265 Count Nodes Equal to Average of Subtree
2316 Count Unreachable Pairs of Nodes in an Undirected Graph
2322 Minimum Score After Removals on a Tree
2328 Number of Increasing Paths in a Grid
2331 Evaluate Boolean Binary Tree
2359 Find Closest Node to Given Two Nodes
2360 Longest Cycle in a Graph
2368 Reachable Nodes With Restrictions
2385 Amount of Time for Binary Tree to Be Infected
2415 Reverse Odd Levels of Binary Tree
2440 Create Components With Same Value
2458 Height of Binary Tree After Subtree Removal Queries
2467 Most Profitable Path in a Tree
2476 Closest Nodes Queries in a Binary Search Tree
2477 Minimum Fuel Cost to Report to the Capital
2492 Minimum Score of a Path Between Two Cities
2493 Divide Nodes Into the Maximum Number of Groups
2538 Difference Between Maximum and Minimum Price Sum
2556 Disconnect Path in a Binary Matrix by at Most One Flip
2581 Count Number of Possible Root Nodes
2596 Check Knight Tour Configuration
2641 Cousins in Binary Tree II
2646 Minimize the Total Price of the Trips
2658 Maximum Number of Fish in a Grid
2685 Count the Number of Complete Components
2791 Count Paths That Can Form a Palindrome in a Tree
2858 Minimum Edge Reversals So Every Node Is Reachable
2867 Count Valid Paths in a Tree
2872 Maximum Number of K-Divisible Components
2920 Maximum Points After Collecting Coins From All Nodes
2925 Maximum Score After Applying Operations on a Tree
2973 Find Number of Coins to Place in Tree Nodes
3067 Count Pairs of Connectable Servers in a Weighted Tree Network
3123 Find Edges in Shortest Paths
3203 Find Minimum Diameter After Merging Two Trees
3235 Check if the Rectangle Corner Is Reachable
3241 Time Taken to Mark All Nodes
3249 Count the Number of Good Nodes
3310 Remove Methods From Project
3319 K-th Largest Perfect Subtree Size in Binary Tree
3327 Check if DFS Strings Are Palindromes
3331 Find Subtree Sizes After Changes
3367 Maximize Sum of Weights after Edge Removals
3372 Maximize the Number of Target Nodes After Connecting Trees I
3373 Maximize the Number of Target Nodes After Connecting Trees II
3376 Minimum Time to Break Locks I
3387 Maximize Amount After Two Days of Conversions
3419 Minimize the Maximum Edge Weight of Graph
3425 Longest Special Path
3486 Longest Special Path II
3493 Properties Graph
3515 Shortest Path in a Weighted Tree
3528 Unit Conversion I
3544 Subtree Inversion Sum
3553 Minimum Weighted Subgraph With the Required Paths II
3558 Number of Ways to Assign Edge Weights I
3559 Number of Ways to Assign Edge Weights II
3562 Maximum Profit from Trading Stocks with Discounts
3575 Maximum Good Subtree Score
3585 Find Weighted Median Node in Tree
3590 Kth Smallest Path XOR Sum
3593 Minimum Increments to Equalize Leaf Paths
3607 Power Grid Maintenance
3619 Count Islands With Total Value Divisible by K
3710 Maximum Partition Factor
3715 Sum of Perfect Square Ancestors
3772 Maximum Subgraph Score in a Tree
3786 Total Sum of Interaction Cost in Tree Groups
3812 Minimum Edge Toggles on a Tree