You are given the root of a binary tree. Your task is to find its minimum depth — the number of nodes along the shortest path from the root node down to the nearest leaf node.
A leaf node is a node with no left or right child.
Return the minimum number of nodes present on any root-to-leaf path.
Input: root = [3,9,20,null,null,15,7]
Output: 2
Explanation: The shortest root-to-leaf path is 3 → 9, which contains 2 nodes.
Input: root = [2,null,3,null,4,null,5,null,6]
Output: 5
Explanation: The tree is skewed, so the only root-to-leaf path has 5 nodes.
Input: root = []
Output: 0
Explanation: An empty tree has a minimum depth of 0.
Sign in to write, run, and submit your solution against the full test suite.