题目:
https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/
答案:
二叉树递归:
public int minDepth(TreeNode root) {
if(root==null) return 0;
if(root.left==null) return minDepth(root.right)+1;
if(root.right==null) return minDepth(root.left)+1;
int leftMinDepth = minDepth(root.left)+1;
int rightMinDepth = minDepth(root.right)+1;
return Math.min(leftMinDepth,rightMinDepth);
}