Wednesday, July 9, 2014

[Leetcode] 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.

Other definition of depth and height
  • The depth of a node is the number of edges from the node to the tree's root node.
A root node will have a depth of 0.

  • The height of a node is the number of edges on the longest path from the node to a leaf.
A leaf node will have a height of 0.

Code


No comments:

Post a Comment