#-*- 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的更多相关文章

  1. [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 ...

  2. 【leetcode❤python】110. Balanced Binary Tree

    #-*- coding: UTF-8 -*-#平衡二叉树# Definition for a binary tree node.# class TreeNode(object):#     def _ ...

  3. <LeetCode OJ> 226. Invert Binary Tree

    226. Invert Binary Tree Total Accepted: 57653 Total Submissions: 136144 Difficulty: Easy Invert a bi ...

  4. 【LeetCode】226. Invert Binary Tree 翻转二叉树(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 迭代 日期 题目地址: https://lee ...

  5. 【一天一道LeetCode】#226. Invert Binary Tree

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 来源:http ...

  6. 【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 ...

  7. 【easy】226. Invert Binary Tree 反转二叉树

    /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...

  8. 【leetcode❤python】 67. Add Binary

    class Solution(object):    def addBinary(self, a, b):        """        :type a: str  ...

  9. Python解Leetcode: 226. Invert Binary Tree

    leetcode 226. Invert Binary Tree 倒置二叉树 思路:分别倒置左边和右边的结点,然后把根结点的左右指针分别指向右左倒置后返回的根结点. # Definition for ...

随机推荐

  1. nginx for windows中的一项缺陷

    按照官网上的说法,使用 start nginx 启动 nginx,使用 nginx -s quit 可以优雅地退出. 经实验,使用 start nginx 之后,会启动两个 nginx 的进程,据官网 ...

  2. 项目中empty遇到的一个问题

    搜索传参时,数据能获取到,搜索结果不是根据参数得出的,在定义搜索条件时因为empty引起的一个问题,键为0的值没有获取到, 记住:!empty 已经把0排除了

  3. SQL内连接与外连接的区别【转】

    --表stuid name 1, Jack2, Tom3, Kity4, nono--表examid grade1, 562, 7611, 89 内连接 (显示两表id匹配的)select stu.i ...

  4. top 介绍

    本文转自:http://www.2cto.com/os/201209/157960.html,感谢作者的辛勤付出! top命令经常用来监控linux的系统状况,比如cpu.内存的使用,程序员基本都知道 ...

  5. Gson将参数放入实体类中进行包装之后再传递

    package com.sinoservices.dms.orderinfo.entity; public class OrderDetailKeyCondition { //工单主键 private ...

  6. linux设备驱动归纳总结(二):模块的相关基础概念【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-59415.html linux设备驱动归纳总结(二):模块的相关基础概念 系统平台:Ubuntu 10 ...

  7. 【python cookbook】【字符串与文本】9.将Unicode文本统一表示为规范形式

    问题:确保所有的Unicode字符串都拥有相同的底层 解决方案:为解决同一个文本拥有多种不同的表示形式问题,应该先将文本统一表示为规范形式,这可以通过unicodedata模块来完成, unicode ...

  8. Creater中选择一行的方法

    1.  在表布局中增加一单选钮列,给单选钮的属性name任意设定一个值.2.  选择单选钮对应列,将其selectID设为单选钮的ID;将onclick设为setTimeout('initAllRow ...

  9. linux添加somebody到组

    添加xiluhua到组:test_group usermod -a test_group  xiluhua

  10. ectouch第五讲 之表

    Ectouch本身相关的表 17个ecs_touch_activity[touch优惠活动扩展表] 优惠活动的自增id 取值ecs_favourable_activity表cat_id,给优惠活动加b ...