Back to course home
0% completed
Solution: Minimum Depth of a Binary Tree
Problem Statement
Find the minimum depth of a binary tree. The minimum depth is the number of nodes along the shortest path from the root node to the nearest leaf node.
Example 1:
Example 2:
Constraints:
- The number of nodes in the tree is in the range [0, 10<sup>5</sup>].
-1000 <= Node.val <= 1000
Solution
This problem follows the Binary Tree Level Order Traversal pattern. We can follow the same BFS approach. The only difference will be, instead of keeping track of all the nodes in a level, we will only track the depth of the tree
.....
.....
.....
Like the course? Get enrolled and start learning!