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.
此时,树的最短高为2
当有一颗子树为空时,最短高为另一颗高度加1
当子树都不为空时,为left和right的最短高加1
1 | /** |
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.
此时,树的最短高为2
当有一颗子树为空时,最短高为另一颗高度加1
当子树都不为空时,为left和right的最短高加1
1 | /** |