两次递归

树的子结构

http://www.nowcoder.com/questionTerminal/6e196c44c7004d15b1610b9afca8bd88

class Solution:
    def HasSubtree(self, s, t):
        def sametree(p,q):
            if p is None and q is None:
                return True
            elif p is not None and q is not None and p.val==q.val:
                return sametree(p.left,q.left) and sametree(p.right,q.right)
            elif p is not None and q is None:
                return True
            else:
                return False
        def subtree(s,t):
            if s is None or t is None:return False
            if sametree(s,t):
                return True
            return subtree(s.left,t) or subtree(s.right,t)
        return subtree(s,t)

两次递归

全部评论

相关推荐

在下uptown:山东的哥们得好好回答 第一问题,专业技能太少了,现在写的大部分都是模型迭代过渡期的技术栈,说白了今天用明天可能就不用,多补一些看家的本事 第二个问题,项目偏学术学习体现不出工程能力,deepresearch核心在于模型自我反馈自我纠正,没体现出来,RAG本身在落地应用上就是个伪命题。 再有就是,有实习经历可以弥补学历不足,建议放到学历下面,别人筛简历可能第一眼觉得学校不过关,但第二眼有实习经历,就给你面试了,藏到后面可能就没有第二眼了
点赞 评论 收藏
分享
评论
4
收藏
分享

创作者周榜

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