[leetcode tree]100. Same Tree
判断输入的两棵树是不是相同
判断当前root值,左子树和右子树是否相同
####注意最后用的是 is 而不是 ==,因为最后判断p和q是不是None, 应该判断是不是同一个对象
class Solution(object):
def isSameTree(self, p, q):
if p and q:
return self.isSameTree(p.left,q.left) and self.isSameTree(p.right,q.right) and p.val==q.val
return p is q
[leetcode tree]100. Same Tree的更多相关文章
- Leetcode 笔记 100 - Same Tree
题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...
- LeetCode之100. Same Tree
------------------------------------------ 递归比较即可 AC代码: /** * Definition for a binary tree node. * p ...
- 【一天一道LeetCode】#100. Same Tree(100题大关)
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given t ...
- 【LeetCode】100. Same Tree 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 [LeetCode] 题目地址:https:/ ...
- 【LeetCode】100 - Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...
- LeetCode OJ 100. Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...
- 【LeetCode】100. Same Tree (2 solutions)
Same Tree Given two binary trees, write a function to check if they are equal or not. Two binary tre ...
- 100.Same Tree(E)
100. same tree 100. Same Tree Given two binary trees, write a function to check if they are the same ...
- <LeetCode OJ> 100. Same Tree
100. Same Tree Total Accepted: 100129 Total Submissions: 236623 Difficulty: Easy Given two binary tr ...
随机推荐
- POJ 1350 Cabric Number Problem (模拟)
题目链接 Description If we input a number formed by 4 digits and these digits are not all of one same va ...
- 关于数据区间变换及numpy数组转图片数据的python实现
python实现区间转换.numpy图片数据转换 需求: 客户的需求是永无止境的,这不?前几天,用户提出了一个需求,需要将一组数据从一个区间缩放到另一区间? 思路: 先将数据归一化,再乘以对应区间的差 ...
- 【微服务架构】SpringCloud之Ribbon
一:Ribbon是什么? Ribbon是Netfix发布的开源项目,主要负责客户端的软件负载均衡算法,将Netfix的中间层连接在一起,Ribbon客户端组件提供一系列完善的配置项如连接超时,重试等. ...
- [Openwrt扩展中篇]添加Aria2和webui
上一篇说了我构建了简单的网络硬盘,这一篇说的是我构造的aria2和webui,大概是这样我觉得有了网络硬盘,那么我是不是可以远程下载呢,翻阅了网上资料发现迅雷的Xware貌似不更新了,然后我发现了ar ...
- Multiple HTTPS Bindings IIS 7 Using appcmd
http://toastergremlin.com/?p=308 Sometimes when using a wildcard SSL or Unified Communications Certi ...
- Linux USB驱动学习总结(三)---- USB鼠标的加载、初始化和通信过程
1.usbmouse的定义:usb鼠标既包含usb设备(usb_device)的属性也包含input输入设备(input_dev)的属性 struct usb_mouse { ];///USB鼠标设备 ...
- c# CTS 基础数据类型笔记
C#中的基础数据类型并没有内置于c#语言中,而内置于.net freamework. C#有15个预定义类型,其中13个是值类型,两个是引用类型(string和object) 一.值类型 值类型 数据 ...
- github 优秀的开源项目
https://github.com/wlcaption/AndroidMarket---- 这是手机应用商店,包含应用的下载,用户中心等内容 https://github.com/wlcaption ...
- spring boot jpa 多数据源配置
在实际项目中往往会使用2个数据源,这个时候就需要做额外的配置了.下面的配置在2.0.1.RELEASE 测试通过 1.配置文件 配置两个数据源 spring.datasource.url=jdbc:m ...
- 【鬼脸原创】谷歌扩展--知乎V2.0
目的: 用键盘替代鼠标,做一个安静刷知乎的美男(女)子! 功能: 功能 按键 说明 直接定位到搜索框 q 打开 首页 w 打开 话题 e 打开 发现 r 打开 消息 m 打开 ...