LeetCode p111 Minimum Depth of Binary Tree 题解
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.解题思路:
注意子节点左右都为空。具体见代码。
3.代码
1 |
|