【leetcode❤python】226. Invert Binary Tree
#-*- coding: UTF-8 -*-
# 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 invertTree(self, root):
if root==None:return None
tempRoot=root.left
root.left=root.right
root.right=tempRoot
self.invertTree(root.right)
self.invertTree(root.left)
return root
【leetcode❤python】226. Invert Binary Tree的更多相关文章
- [LeetCode&Python] Problem 226. Invert Binary Tree
Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 Tr ...
- 【leetcode❤python】110. Balanced Binary Tree
#-*- coding: UTF-8 -*-#平衡二叉树# Definition for a binary tree node.# class TreeNode(object):# def _ ...
- <LeetCode OJ> 226. Invert Binary Tree
226. Invert Binary Tree Total Accepted: 57653 Total Submissions: 136144 Difficulty: Easy Invert a bi ...
- 【LeetCode】226. Invert Binary Tree 翻转二叉树(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 迭代 日期 题目地址: https://lee ...
- 【一天一道LeetCode】#226. Invert Binary Tree
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 来源:http ...
- 【LeetCode】226 - Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Notice: Goog ...
- 【easy】226. Invert Binary Tree 反转二叉树
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...
- 【leetcode❤python】 67. Add Binary
class Solution(object): def addBinary(self, a, b): """ :type a: str ...
- Python解Leetcode: 226. Invert Binary Tree
leetcode 226. Invert Binary Tree 倒置二叉树 思路:分别倒置左边和右边的结点,然后把根结点的左右指针分别指向右左倒置后返回的根结点. # Definition for ...
随机推荐
- form文件上传,防止页面刷新
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>文件上传 ...
- highcharts 实例
<script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript">< ...
- 利用API自动建立GL科目段组合
1.检查存在性,如没有则新增 fnd_flex_keyval.validate_segs('CREATE_COMBINATION' ...
- 夺命雷公狗TP下关联查询
记录下我们常用的关联查询: public function add4(){ $id=$_GET['id']; $this->list = M("student")->t ...
- HTML5游戏引擎Phaser初体验
首发:个人博客,更新&纠错&回复 一个小小的游戏在这里,试试看能不能过关?提示一下,方向键走路,空格键发炮,每发炮弹消耗12个积分,变大情况下可以发炮. 每秒60次的循环重绘,在其中判 ...
- zabbix agent 类型自带的key
zabbix服务器端通过与zabbix agent通信来获取客户端服务器的数据,agent分为两个版本,在配置主机我们可以看到一个是agent,另一个是agent(active). agent:zab ...
- kvm虚拟机virt-manager启动报错
安装kvm,用virt-manager启动时报错如下: Traceback (most recent call last): File "/usr/share/virt-manager/v ...
- Environment中针对的读写权限判断
Android应用开发中,常使用Environment类去获取外部存储目录,在访问外部存储之前一定要先判断外部存储是否已经是可使用(已挂载&可使用)状态,并且需要在AndroidManifes ...
- Java中类方法与实例方法的区别
实例方法可以对当前对象的实例变量进行操作,也可以对类变量进行操作,但类方法不能访问实例变量.实例方法必须由实例对象来调用,而类方法除了可由实例对象调用外,还可以由类名直接调用. 另外,在类方法中不能使 ...
- SQL中char、varchar、nvarchar的区别
char char是定长的,也就是当你输入的字符小于你指定的数目时,char(8),你输入的字符小于8时,它会再后面补空值.当你输入的字符大于指定的数时,它会截取超出的字符. nvarcha ...