226. Invert Binary Tree
来源:互联网 发布:中企动力域名管理 编辑:程序博客网 时间:2024/05/22 00:54
Invert a binary tree.
4 / \ 2 7 / \ / \1 3 6 9to
4 / \ 7 2 / \ / \9 6 3 1
解题思路:
利用递归方式解决,左孩子为右递归,右孩子为左递归。
Java-Solution:
public class Solution {public TreeNode invertTree(TreeNode root) {if(root == null)return null;TreeNode temp = root.left;root.left = invertTree(root.right);root.right = invertTree(temp);return root; }}
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
- ElasticSearch之定时删除数据
- qduoj 农场主良辰(感谢cqupt...
- 【C#】C#中遍历文件夹下的目录文件
- 重载和重写的编码区别及JVM编译区别
- Android Studio中使应用全屏无标题的方法(老方法好像不能用了)
- 226. Invert Binary Tree
- Ubuntu Linux 安装 .7z 解压和压缩文件
- 关于log4j Properties放在不同路径下的问题
- Ionic简单接触:Windows下Ionic Android开发环境搭建
- 欢迎使用CSDN-markdown编辑器
- RabbitMQ 安装后无法启动服务
- spring配置jpa
- c/c++文件头注释格式
- [ios开发异常]whose view is not in the window hierarchy!