Given a binary tree, write a program to find its minimum depth.

Problem Note

  • The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
  • A leaf is a node with no children.

Example 1

Input: Given a binary tree [10,5,15,null,null,11,6]
    10
   / \
  5  15
    /  \
   11   6
Output: 2

Example 2

Input: Given a binary tree [1,null,2]
         1
          \
           2
Output: 2