111. Minimum Depth of Binary Tree

来源:互联网 发布:ppt录制旁白软件 编辑:程序博客网 时间:2024/06/10 05:01
public class Solution {
    public int minDepth(TreeNode root) {
        if(root==null)return 0;
        int l=minDepth(root.left);
        int r=minDepth(root.right);
        if(l==0||r==0)return l+r+1;
        return Math.min(l,r)+1;
    }
}
0 0