leetcode Same Tree python
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None class Solution(object):
def isSameTree(self, p, q):
"""
:type p: TreeNode
:type q: TreeNode
:rtype: bool
"""
if p == None and q == None:
return True
if p and q and p.val == q.val:
return self.isSameTree(p.right,q.right) and self.isSameTree(p.left,q.left)
return False
leetcode Same Tree python的更多相关文章
- [leetcode]Symmetric Tree @ Python
原题地址:https://oj.leetcode.com/problems/symmetric-tree/ 题意:判断二叉树是否为对称的. Given a binary tree, check whe ...
- LeetCode:Binary Tree Level Order Traversal I II
LeetCode:Binary Tree Level Order Traversal Given a binary tree, return the level order traversal of ...
- LeetCode: Binary Tree Traversal
LeetCode: Binary Tree Traversal 题目:树的先序和后序. 后序地址:https://oj.leetcode.com/problems/binary-tree-postor ...
- [LeetCode]题解(python):114 Flatten Binary Tree to Linked List
题目来源 https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ Given a binary tree, flatten ...
- [LeetCode]题解(python):111 Minimum Depth of Binary Tree
题目来源 https://leetcode.com/problems/minimum-depth-of-binary-tree/ Given a binary tree, find its minim ...
- [LeetCode]题解(python):110 Balanced Binary Tree
题目来源 https://leetcode.com/problems/balanced-binary-tree/ Given a binary tree, determine if it is hei ...
- [LeetCode]题解(python):107 Binary Tree Level Order Traversal II
题目来源 https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ Given a binary tree, return ...
- [LeetCode]题解(python):104 Maximum Depth of Binary Tree
题目来源 https://leetcode.com/problems/maximum-depth-of-binary-tree/ Given a binary tree, find its maxim ...
- [LeetCode]题解(python):103 Binary Tree Zigzag Level Order Traversal
题目来源 https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ Given a binary tree, re ...
随机推荐
- ubuntu 11.04安装笔记
首先,本文查询了网络中各位大大的经验共享,特别是<UltraISO制作U盘启动Ubuntu 8.10 LiveCD>,地址在http://blog.sina.com.cn/s/blog_5 ...
- DictoryInfo.GetFiles
using System; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(stri ...
- javascript模式——Facade
Facade模式为许多代码提供一个方便的接口,不现实代码实现的复杂性,这样,使用者只需要关心他的使用接口就可以使用. 下面来看一段Facade模式的运用,绑定事件在浏览器之间是不一样的,利用Facad ...
- php中的一些编程例子
#一到一百不能被三整除的数 for($i=1;$i<=100;$i++){ if($i%3 != 0){ $arr[] = $i; }} var_dump($arr); #水仙花数for($i= ...
- title:EL表达式获取Map里面的数值失败的问题
在控制器中定义了一个Map<Integer,String>集合,看似没有问题,将这个集合的对象map传递到一个JSP页面中,我们都知道,用EL表达式 ${map[key]}就可以取得key ...
- Python简明教程---学习笔记
字符双引号括起,数字不括: 分隔符为逗号(,),不能为空格 变量定义时即赋值 采用utf-8编码:#-*-coding:utf-8-*-或者#coding:utf-8 字符串定义:单/双引号括起 %符 ...
- Http Analyzer 数据抓包
一.工具简介 这是一款实时分析 HTTP/HTTPS 数据流的工具.它可以实时捕捉HTTP/HTTPS 协议数据,可以显示许多信息(包括:文件头.内容.Cookie.查询字符窜.提交的数据.重定向的U ...
- opencv如何截取子图像
首先用GetSubRect函数确定子图像的区域 GetSubRect 返回输入的图像或矩阵的矩形数组子集的矩阵头 CvMat* cvGetSubRect( const CvArr* arr, CvM ...
- Oracle EBS-SQL (WIP-5):检查非标任务本身选上了MRP净值.sql
SELECT WE.WIP_ENTITY_NAME, MSI.SEGMENT1, MSI.DESCRIPTION, WDJ.CLASS ...
- listview及adapter
http://blog.csdn.net/shaojie519/article/details/6595720 http://blog.csdn.net/liuhe688/article/detail ...