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