All problems
› DFS problems
DFS problems
108 DFS DSA practice problems on CampusCode, each with statement, examples and constraints.
542. Swim in Rising Water
Hard
Binary Search
543. Minimum Number of Days to Disconnect Island
Hard
Binary Search
835. Inorder Traversal of Binary Tree
Easy
Trees
836. Preorder Traversal of Binary Tree
Easy
Trees
837. Postorder Traversal of Binary Tree
Easy
Trees
839. Height / Maximum Depth of Binary Tree
Easy
Trees
840. Minimum Depth of Binary Tree
Easy
Trees
841. Count Total Nodes in Binary Tree
Easy
Trees
842. Count Leaf Nodes
Easy
Trees
843. Sum of All Nodes
Easy
Trees
844. Check if Two Trees are Identical
Easy
Trees
845. Mirror / Invert a Binary Tree
Easy
Trees
846. Check if Binary Tree is Symmetric
Easy
Trees
847. Check if Binary Tree is Balanced
Easy
Trees
848. Diameter of Binary Tree
Easy
Trees
849. Maximum Path Sum Root to Leaf
Easy
Trees
850. Check if Path with Given Sum Exists
Easy
Trees
851. Find All Root-to-Leaf Paths
Easy
Trees
857. Boundary Traversal of Binary Tree
Easy
Trees
860. Check if Binary Tree is Full
Easy
Trees
861. Check if Binary Tree is Perfect
Easy
Trees
863. Find Lowest Common Ancestor (LCA)
Easy
Trees
864. Find Distance Between Two Nodes
Easy
Trees
867. Check if Leaf Nodes are at Same Level
Easy
Trees
868. Convert Binary Tree to its Mirror
Easy
Trees
869. Sum of Nodes on Longest Path Root to Leaf
Easy
Trees
870. Count Half Nodes in Binary Tree
Easy
Trees
871. Find the Deepest Left Leaf Node
Easy
Trees
880. Check if a Tree is a Valid BST
Easy
Trees
888. Count Nodes in BST with Keys in Given Range
Easy
Trees
893. Check if BST Contains Dead End
Easy
Trees
894. Print BST Keys in Given Range
Easy
Trees
895. Binary Tree Maximum Path Sum
Medium
Trees
898. Flatten Binary Tree to Linked List
Medium
Trees
900. Binary Tree Right Side View
Medium
Trees
901. Sum Root to Leaf Numbers
Medium
Trees
902. Path Sum II — All Root-to-Leaf Paths
Medium
Trees
903. Path Sum III — Any Downward Path
Medium
Trees
904. Count Good Nodes in Binary Tree
Medium
Trees
906. Find Duplicate Subtrees
Medium
Trees
907. Maximum Difference Between Node and Ancestor
Medium
Trees
912. Vertical Order Traversal (Coordinate Sort)
Medium
Trees
913. Check if Two Trees are Isomorphic
Medium
Trees
914. Minimum Time to Collect All Apples
Medium
Trees
915. Longest Univalue Path
Medium
Trees
916. House Robber III — Tree DP
Medium
Trees
917. Distribute Coins in Binary Tree
Medium
Trees
918. Delete Node and Return Forest
Medium
Trees
919. Recover BST — Two Swapped Nodes
Medium
Trees
921. Convert BST to Greater Tree
Medium
Trees
924. Largest BST Subtree
Medium
Trees
933. Pseudo-Palindromic Paths in Binary Tree
Medium
Trees
936. Binary Tree Maximum Path Sum (Any to Any)
Hard
Trees
939. Vertical Order Traversal (Full Coordinate Sort)
Hard
Trees
943. Linked List in Binary Tree
Hard
Trees
961. Maximum Weight Independent Set on a Tree
Hard
Trees
962. Tree Diameter with Weighted Edges
Hard
Trees
963. Minimum Vertex Cover on a Tree
Hard
Trees
964. Minimum Dominating Set on a Tree
Hard
Trees
965. Sum of Distances in Tree (Rerooting)
Hard
Trees
966. Find Duplicate Subtrees (Hashing)
Hard
Trees
967. Distribute Coins in Binary Tree (Minimum Moves)
Hard
Trees
975. DFS Traversal of Undirected Graph
Easy
Graphs
977. DFS Traversal of Directed Graph
Easy
Graphs
979. Check if Path Exists Between Two Nodes
Easy
Graphs
981. Count Connected Components in Undirected Graph
Easy
Graphs
983. Check if Graph is Bipartite
Easy
Graphs
984. Detect Cycle in Undirected Graph (DFS)
Easy
Graphs
985. Detect Cycle in Directed Graph (DFS)
Easy
Graphs
989. Number of Islands (DFS)
Easy
Graphs
990. Flood Fill Algorithm
Easy
Graphs
991. Max Area of Island
Easy
Graphs
993. Surrounded Regions — Capture Os
Easy
Graphs
994. Pacific Atlantic Water Flow
Easy
Graphs
998. Check if There is a Valid Path in Grid
Easy
Graphs
1000. Number of Closed Islands
Easy
Graphs
1001. Number of Enclaves
Easy
Graphs
1002. Count Sub Islands
Easy
Graphs
1005. Find if Path Exists in Grid
Easy
Graphs
1006. Count Reachable Nodes from a Source
Easy
Graphs
1007. Coloring Border
Easy
Graphs
1012. Topological Sort Using DFS
Easy
Graphs
1014. Check if a Directed Graph is a DAG
Easy
Graphs
1015. Course Schedule I — Can Finish All Courses
Easy
Graphs
1016. Find Mother Vertex in Directed Graph
Easy
Graphs
1017. Print All Paths Between Two Nodes
Easy
Graphs
1019. Find All Articulation Points (Bridges Intro)
Easy
Graphs
1021. Clone an Undirected Graph
Easy
Graphs
1025. Count Paths from Source to Destination in DAG
Easy
Graphs
1039. Critical Connections — Bridges in Graph
Medium
Graphs
1043. Find All Ancestors of a Node in DAG
Medium
Graphs
1046. Kosaraju's Algorithm — Strongly Connected Components
Medium
Graphs
1047. Tarjan's Algorithm — SCC
Medium
Graphs
1048. Count Strongly Connected Components
Medium
Graphs
1053. Making a Large Island
Medium
Graphs
1060. Number of Provinces — Connected Components
Medium
Graphs
1061. Keys and Rooms
Medium
Graphs
1062. Find Eventual Safe States
Medium
Graphs
1063. Reconstruct Itinerary (Eulerian Path)
Medium
Graphs
1064. Graph Valid Tree
Medium
Graphs
1065. Maximal Network Rank
Medium
Graphs
1080. Max Flow — Ford-Fulkerson Algorithm
Hard
Graphs
1086. Count Critical Nodes Whose Removal Disconnects Graph
Hard
Graphs
1101. Minimum Days to Disconnect Island
Hard
Graphs
1102. Number of Increasing Paths in Grid
Hard
Graphs
1104. Find All Bridges Using Tarjan's Algorithm
Hard
Graphs
1105. Articulation Points Using Tarjan's Algorithm
Hard
Graphs
1106. Eulerian Circuit Using Hierholzer's Algorithm
Hard
Graphs