Given the root of a binary tree, return the minimum depth of the tree.
The minimum depth is the number of nodes along the shortest path from root down to the nearest leaf node. A leaf node is a node that has no children.
Note: A leaf node is defined as a node with neither a left child nor a right child.
Constraints:
The number of nodes in the tree is in the range
Node.val
Given the root of a binary tree, return the minimum depth of the tree.
The minimum depth is the number of nodes along the shortest path from root down to the nearest leaf node. A leaf node is a node that has no children.
Note: A leaf node is defined as a node with neither a left child nor a right child.
Constraints:
The number of nodes in the tree is in the range
Node.val