-------------------------------------

反转树的基本操作。

可是下面那句话是什么鬼啊,这么牛掰的人都会有这种遭遇,确实抚慰了一点最近面试被拒的忧伤.....

AC代码:

/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public TreeNode invertTree(TreeNode root) {
if(root==null) return null; TreeNode t=root.left;
root.left=invertTree(root.right);
root.right=invertTree(t); return root;
}
}

题目来源: https://leetcode.com/problems/invert-binary-tree/

LeetCode之226. Invert Binary Tree的更多相关文章

  1. Python解Leetcode: 226. Invert Binary Tree

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

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

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

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

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

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

  5. LeetCode OJ 226. Invert Binary Tree

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia:This problem was ...

  6. <LeetCode OJ> 226. Invert Binary Tree

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

  7. LeetCode Javascript实现 258. Add Digits 104. Maximum Depth of Binary Tree 226. Invert Binary Tree

    258. Add Digits Digit root 数根问题 /** * @param {number} num * @return {number} */ var addDigits = func ...

  8. C#版 - 226. Invert Binary Tree(剑指offer 面试题19) - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - 2 ...

  9. 226. Invert Binary Tree(C++)

    226. Invert Binary Tree Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 ...

随机推荐

  1. 使用VS Code 从零开始开发并调试.NET Core 应用程序

    最新文章:http://www.cnblogs.com/linezero/p/VSCodeNETCore.html 使用VS Code 从零开始开发并调试.NET Core 应用程序,C#调试. 上一 ...

  2. Object Removal by Exemplar-Based Inpainting 概括(附源码)

    关于这篇论文:其是采用基于样例的图像修复,通俗地讲就是图像其他部分的采样信息去填补遮挡区域,其与使用扩散方法的图像修补方法相比,不会产生模糊效应. 论文中涉及到的几个参数     Ω:要修补的区域 δ ...

  3. LinuxMint 18 编译cm13.0 笔记

    1.安装依赖文件 sudo apt--dev libesd0-dev git-core gnupg flex bison gperf build-essential zip curl zlib1g-d ...

  4. gulp-rev-collector自定义修改rev-manifest.json后替换不成功的问题分析

    由于项目需要,我要把common.js替换成build.min.js,接着后面才用到build.min.js=>build-te234ds.min.js这样的形式替换,但是我发现怎么替换都不能把 ...

  5. wpf converter converterparameter 绑定多参数

    1. converterparameter不是依赖属性,所以不能用binding. 2. 可以把converter 的接口 IValueConverter改为 IMultiValueConverter ...

  6. Join Attributes

    1. IWorkspaceFactory2 workspaceFactory = new ShapefileWorkspaceFactoryClass() as IWorkspaceFactory2; ...

  7. C++计算几何库

    http://www.cgal.org/ http://shapeop.org/

  8. maven install时报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile

    首先检查父项目,子项目的jdk版本是否一致,编码格式是否一致我的问题就错在了编码格式上,父项目用的是UTF-8,子项目新建的,默认GBK这时,使用maven install命令出错 提示:[INFO] ...

  9. ASP.NET 导出数据表格

    功能:可以实现导出整个数据表格或整个页面 public bool ExportGv(string fileType, string fileName)        {            bool ...

  10. UI第十四节——UIAlertController

    - (void)viewDidLoad {    [super viewDidLoad];        UIButton *alertBtn = [UIButton buttonWithType:U ...