class Solution {
public int minDepth(TreeNode root) {
if(root==null)return 0;
else if(root.left==null)return minDepth(root.right)+1;
else if(root.right==null)return minDepth(root.left)+1;
else return Math.min(minDepth(root.left),minDepth(root.right))+1;
}
}
二叉树的最小深度
最新推荐文章于 2025-12-26 21:45:18 发布

1837

被折叠的 条评论
为什么被折叠?



