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. Hide Tags Tree Depth-first Search 这题是找二叉树的最小深度,这是广度搜索比较好吧,为啥提示给的是 深度优先呢. 判断树是否为空 将ro…
题目: minimum-depth-of-binary-tree 要求: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. 思路: 两种方法: 第一,使用递归,相当于遍历了整个二叉树,递归返回深度浅的那棵子树的深度. 第二,按层检查…
题目: 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. 思路1:利用递归遍历,求最小深度 //递归遍历求最小深度 class Solution { public: int run(TreeNode *root) { if(root…
http://www.lintcode.com/zh-cn/problem/minimum-depth-of-binary-tree/ 题目描述信息 /** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, right; * public TreeNode(int val) { * this.val = val; * …