logo
Problems

Minimum Depth of Binary Tree

Problem

Given a binary tree, find its minimum depth.

The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.

Example

Given a binary tree as follow:

      1
     / \
    2   3
       / \
      4   5

The minimum depth is 2.

Online Judge