码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode——100.相同的树

时间:2019-09-24 17:55:56      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:inf   内存   现在   false   class   lse   else   nbsp   self   

class Solution:
    def isSameTree(self, p, q) -> bool:
        if not p and not q:
            return True
        elif p is not None and q is not None:
            if p.val==q.val:
                return self.isSameTree(p.left,q.left) and self.isSameTree(p.right,q.right)
            else:
                return False
        else:
            return False

 

执行用时 :40 ms, 在所有 Python3 提交中击败了95.91%的用户
内存消耗 :13.8 MB, 在所有 Python3 提交中击败了5.10%的用户
 
难过,我还是不知道它怎么输入的。。。。。
 
我现在好瞌睡。。。。
                                                                                                 ——2019.9.24

leetcode——100.相同的树

标签:inf   内存   现在   false   class   lse   else   nbsp   self   

原文地址:https://www.cnblogs.com/taoyuxin/p/11579336.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!