找出根到叶子结点的距离的最小值

//找出根到叶子结点的距离的最小值
public int minDepth(TreeNode root){
	if(root == null){
		return 0;
	}
	int left = minDepth(root.left);
	int right = minDepth(root.right);
	if(left == 0 || right == 0) ? left + right + 1 : Math.min(left,right) + 1;
}

你可能感兴趣的:(每日编程)