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

//找出根到叶子结点的距离的最小值
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;
}

猜你喜欢

转载自blog.csdn.net/qq_25499519/article/details/80468292