Depth-First Search | LeetCode Problems

174 Depth-First Search solutions to LeetCode solutions.

Depth-First Search Problems View all solutions →

Word Search

#79 Medium

Binary Tree Inorder Traversal

#94 Easy

Validate Binary Search Tree

#98 Medium

Recover Binary Search Tree

#99 Medium

Same Tree

#100 Easy

Symmetric Tree

#101 Easy

Maximum Depth of Binary Tree

#104 Easy

Balanced Binary Tree

#110 Easy

Minimum Depth of Binary Tree

#111 Easy

Path Sum

#112 Easy

Path Sum II

#113 Medium

Flatten Binary Tree to Linked List

#114 Medium

Populating Next Right Pointers in Each Node

#116 Medium

Populating Next Right Pointers in Each Node II

#117 Medium

Binary Tree Maximum Path Sum

#124 Hard

Sum Root to Leaf Numbers

#129 Medium

Surrounded Regions

#130 Medium

Clone Graph

#133 Medium

Binary Tree Preorder Traversal

#144 Easy

Binary Tree Postorder Traversal

#145 Easy

Binary Tree Right Side View

#199 Medium

Number of Islands

#200 Medium

Course Schedule

#207 Medium

Course Schedule II

#210 Medium

Design Add and Search Words Data Structure

#211 Medium

Invert Binary Tree

#226 Easy

Kth Smallest Element in a BST

#230 Medium

Lowest Common Ancestor of a Binary Search Tree

#235 Easy

Lowest Common Ancestor of a Binary Tree

#236 Medium

Binary Tree Paths

#257 Easy

Serialize and Deserialize Binary Tree

#297 Hard

Minimum Height Trees

#310 Medium

Longest Increasing Path in a Matrix

#329 Hard

Reconstruct Itinerary

#332 Hard

House Robber III

#337 Medium

Flatten Nested List Iterator

#341 Medium

Water and Jug Problem

#365 Medium

Mini Parser

#385 Medium

Lexicographical Numbers

#386 Medium

Longest Absolute File Path

#388 Medium

Evaluate Division

#399 Medium

Sum of Left Leaves

#404 Easy

Pacific Atlantic Water Flow

#417 Medium

Battleships in a Board

#419 Medium

Flatten a Multilevel Doubly Linked List

#430 Medium

Path Sum III

#437 Medium

Serialize and Deserialize BST

#449 Medium

Island Perimeter

#463 Medium

Concatenated Words

#472 Hard

Find Mode in Binary Search Tree

#501 Easy

Most Frequent Subtree Sum

#508 Medium

Find Bottom Left Tree Value

#513 Medium

Freedom Trail

#514 Hard

Find Largest Value in Each Tree Row

#515 Medium

Minesweeper

#529 Medium

Minimum Absolute Difference in BST

#530 Easy

Convert BST to Greater Tree

#538 Medium

Diameter of Binary Tree

#543 Easy

Number of Provinces

#547 Medium

Maximum Depth of N-ary Tree

#559 Easy

Binary Tree Tilt

#563 Easy

Array Nesting

#565 Medium

Subtree of Another Tree

#572 Easy

N-ary Tree Preorder Traversal

#589 Easy

N-ary Tree Postorder Traversal

#590 Easy

Construct String from Binary Tree

#606 Easy

Merge Two Binary Trees

#617 Easy

Add One Row to Tree

#623 Medium

Average of Levels in Binary Tree

#637 Easy

Find Duplicate Subtrees

#652 Medium

Two Sum IV - Input is a BST

#653 Easy

Print Binary Tree

#655 Medium

Maximum Width of Binary Tree

#662 Medium

Trim a Binary Search Tree

#669 Medium

Second Minimum Node In a Binary Tree

#671 Easy

Bulb Switcher II

#672 Medium

Implement Magic Dictionary

#676 Medium

Redundant Connection

#684 Medium

Redundant Connection II

#685 Hard

Longest Univalue Path

#687 Medium

Employee Importance

#690 Medium

Max Area of Island

#695 Medium

Accounts Merge

#721 Medium

Flood Fill

#733 Easy

Network Delay Time

#743 Medium

Contain Virus

#749 Hard

Cracking the Safe

#753 Hard

Pyramid Transition Matrix

#756 Medium

Couples Holding Hands

#765 Hard

Swim in Rising Water

#778 Hard

Minimum Distance Between BST Nodes

#783 Easy

Is Graph Bipartite?

#785 Medium

Cheapest Flights Within K Stops

#787 Medium

All Paths From Source to Target

#797 Medium

Find Eventual Safe States

#802 Medium

Binary Tree Pruning

#814 Medium

Making A Large Island

#827 Hard

Sum of Distances in Tree

#834 Hard

Similar String Groups

#839 Hard

Keys and Rooms

#841 Medium

Loud and Rich

#851 Medium

All Nodes Distance K in Binary Tree

#863 Medium

Smallest Subtree with all the Deepest Nodes

#865 Medium

Leaf-Similar Trees

#872 Easy

Possible Bipartition

#886 Medium

Increasing Order Search Tree

#897 Easy

Minimize Malware Spread

#924 Hard

Minimize Malware Spread II

#928 Hard

Shortest Bridge

#934 Medium

Range Sum of BST

#938 Easy

Most Stones Removed with Same Row or Column

#947 Medium

Flip Equivalent Binary Trees

#951 Medium

Regions Cut By Slashes

#959 Medium

Univalued Binary Tree

#965 Easy

Binary Tree Cameras

#968 Hard

Flip Binary Tree To Match Preorder Traversal

#971 Medium

Distribute Coins in Binary Tree

#979 Medium

Vertical Order Traversal of a Binary Tree

#987 Hard

Smallest String Starting From Leaf

#988 Medium

Cousins in Binary Tree

#993 Easy

Number of Enclaves

#1020 Medium

Sum of Root To Leaf Binary Numbers

#1022 Easy

Maximum Difference Between Node and Ancestor

#1026 Medium

Recover a Tree From Preorder Traversal

#1028 Hard

Coloring A Border

#1034 Medium

Escape a Large Maze

#1036 Hard

Binary Search Tree to Greater Sum Tree

#1038 Medium

Flower Planting With No Adjacent

#1042 Medium

Insufficient Nodes in Root to Leaf Paths

#1080 Medium

Delete Nodes And Return Forest

#1110 Medium

Lowest Common Ancestor of Deepest Leaves

#1123 Medium

Binary Tree Coloring Game

#1145 Medium

Maximum Level Sum of a Binary Tree

#1161 Medium

Critical Connections in a Network

#1192 Hard

Smallest String With Swaps

#1202 Medium

Sort Items by Groups Respecting Dependencies

#1203 Hard

Remove Sub-Folders from the Filesystem

#1233 Medium

Number of Closed Islands

#1254 Medium

Find Elements in a Contaminated Binary Tree

#1261 Medium

Count Servers that Communicate

#1267 Medium

Deepest Leaves Sum

#1302 Medium

All Elements in Two Binary Search Trees

#1305 Medium

Jump Game III

#1306 Medium

Sum of Nodes with Even-Valued Grandparent

#1315 Medium

Number of Operations to Make Network Connected

#1319 Medium

Delete Leaves With a Given Value

#1325 Medium

Maximum Product of Splitted Binary Tree

#1339 Medium

Validate Binary Tree Nodes

#1361 Medium

Linked List in Binary Tree

#1367 Medium

Longest ZigZag Path in a Binary Tree

#1372 Medium

Maximum Sum BST in Binary Tree

#1373 Hard

Time Needed to Inform All Employees

#1376 Medium

Frog Position After T Seconds

#1377 Hard

Find a Corresponding Node of a Binary Tree in a Clone of That Tree

#1379 Easy

Balance a Binary Search Tree

#1382 Medium

Check if There is a Valid Path in a Grid

#1391 Medium

Minimum Time to Collect All Apples in a Tree

#1443 Medium

Count Good Nodes in Binary Tree

#1448 Medium

Pseudo-Palindromic Paths in a Binary Tree

#1457 Medium

Course Schedule IV

#1462 Medium

Reorder Routes to Make All Paths Lead to the City Zero

#1466 Medium

Kth Ancestor of a Tree Node

#1483 Hard

Number of Nodes in the Sub-Tree With the Same Label

#1519 Medium

Number of Good Leaf Nodes Pairs

#1530 Medium

Detect Cycles in 2D Grid

#1559 Medium

Minimum Number of Days to Disconnect Island

#1568 Hard

Throne Inheritance

#1600 Medium

Lexicographically Smallest String After Applying Operations

#1625 Medium

Path With Minimum Effort

#1631 Medium

Maximum Employees to Be Invited to a Meeting

#2127 Hard

Most Profitable Path in a Tree

#2467 Medium

Divide Nodes Into the Maximum Number of Groups

#2493 Hard

Maximum Number of Fish in a Grid

#2658 Medium

Count the Number of Complete Components

#2685 Medium