哪位大佬帮忙看看这个程序到底哪里错了啊
public class Solution {
    public boolean HasSubtree(TreeNode root1,TreeNode root2) {
        boolean result = false;
        if(root1 != null && root2 != null){
            if(root1.val == root2.val)
                result = tree1ContainsTree2(root1,root2);
            if(!result)
                result = HasSubtree(root1.left,root2);
            if(!result)
                result = HasSubtree(root1.right,root2);
        }
        return result;
    }
    
    public boolean tree1ContainsTree2(TreeNode root1,TreeNode root2){
        if(root1 == null)
            return false;
        if(root2 == null)
            return true;
        if(root1.val != root2.val)
            return false;
        return tree1ContainsTree2(root1.left,root2.left) && tree1ContainsTree2(root1.right,root2.right);
    }
}
全部评论

相关推荐

07-17 11:50
门头沟学院 Java
投递腾讯等公司10个岗位
点赞 评论 收藏
分享
06-11 14:15
已编辑
门头沟学院 后端
田心今心:打招呼改一下,把实习半年以上随时到岗放第一行,因为ssob的hr不点击看的时候只能看前面几个字,你前面几个字hr获取不到什么信息,也就不会点进来看
点赞 评论 收藏
分享
06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务