LeetCode 226
2016-04-24 23:12
225 查看
Invert Binary Tree
Invert a binary tree.
to
Invert a binary tree.
4 / \ 2 7 / \ / \ 1 3 6 9
to
4 / \ 7 2 / \ / \ 9 6 3 1
/** * 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 root; }else{ TreeNode n = root.left; root.left = invertTree(root.right); root.right = invertTree(n); return root; } } }
相关文章推荐
- Uva 10905 Children's Game
- [Perl] 常见signals解析
- 第3章第1节练习题1 蛇形矩阵
- c++作业4
- #include <NOIP2008 Junior> 双栈排序 ——using namespace wxl;
- 20159302《网络攻击与防范》第八周学习总结
- LeetCode 203
- c++ primer(第五版)学习笔记及习题答案代码版(第二章)
- 20145310《Java程序设计》第3次实验报告
- API 双方认证探讨
- PHP——图片上传
- LigerUI中通过加载服务端数据进行表格的分页显示
- sed命令解析
- 程序员怎么在短时间内从菜鸟到高级架构师
- LeetCode 202
- QT基础(三)----QPainter画图功能 & 画图小项目
- 数据库范式
- Win7下尝试编译Fast RCNN---- 一次失败的经历
- spark 性能优化
- Linux系统时间和硬件时间设置