226. Invert Binary Tree
来源:互联网 发布:电视阿里云系统好不好 编辑:程序博客网 时间:2024/06/04 22:10
Invert a binary tree.
4 / \ 2 7 / \ / \1 3 6 9to
4 / \ 7 2 / \ / \9 6 3 1Trivia:
This problem was inspired by this original tweet by Max Howell:
Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off.
Subscribe to see which companies asked this question.
/** * 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) { back(root);return root; } static void back(TreeNode root) {if (root == null)return;TreeNode temp = root.left;root.left = root.right;root.right = temp;back(root.left);back(root.right);}}
0 0
- 226.Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 226. Invert Binary Tree
- 电脑的linux操作系统和windows有什么区别?
- could not find com.android.tools.build:gradle:2.2.3
- Spring Cloud 组件搭建(一)Eureka服务发现
- 模拟留言本————代码实现
- Python之字符串
- 226. Invert Binary Tree
- 基于Netty5.0高级案例之请求响应同步通信
- linux20基本命令
- 关系型数据库三范式
- Python中类的方法属性与方法属性的动态绑定
- vs 调试的时候提示和源码对应不上,断点不起作用
- 【数据结构】二叉树的后序遍历
- com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector
- 对绝对路径与相对路径的理解