zoukankan      html  css  js  c++  java
  • leetcode——100.相同的树

    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
     
    天呐,我之前都菜成什么样了。。。
    public boolean isSameTree(TreeNode p, TreeNode q) {
            if(p == null && q == null){
                return true;
            }else if(p == null || q == null){
                return false;
            }
            if(p.val != q.val){
                return false;
            }
            return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
        }

    人得慢慢进步,后悔这么久都没有做题。。

    ——2020.7.1

    我的前方是万里征途,星辰大海!!
  • 相关阅读:
    大数减法
    MySQL配置的一些坑
    最大流_Edmonds-Karp算法
    最小生成树两连
    最短路三连
    对拍
    Broadcast
    Intent
    Custom Views
    Fragment
  • 原文地址:https://www.cnblogs.com/taoyuxin/p/11579336.html
Copyright © 2011-2022 走看看