Leetcode题解 226. Invert Binary Tree
来源:互联网 发布:网络世界大战视频 编辑:程序博客网 时间:2024/06/06 04:22
Invert a binary tree.
4 / \ 2 7 / \ / \1 3 6 9
to
4 / \ 7 2 / \ / \9 6 3 1
用递归实现
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.
/** * 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(null==root){ return root; } invertTree(root.left); invertTree(root.right); TreeNode temp=root.left; root.left=root.right; root.right=temp; return root; }}
0 0
- leetcode 226. Invert Binary Tree 题解
- Leetcode题解 226. Invert Binary Tree
- LeetCode Algorithms 226. Invert Binary Tree 题解
- LeetCode题解–226. Invert Binary Tree
- LeetCode题解:Invert Binary Tree
- LeetCode题解:Invert Binary Tree
- LeetCode 226. Invert Binary Tree 题解(C++)
- LeetCode 226. Invert Binary Tree 题解 —— Java
- LeetCode 题解(192) : Invert Binary Tree
- LeetCode题解-226-Invert Binary Tree
- LeetCode 226 Invert Binary Tree题解
- LeetCode 226. Invert Binary Tree
- [leetcode] 226.Invert Binary Tree
- [leetcode] 226. Invert Binary Tree
- 【LeetCode】226. Invert Binary Tree
- leetCode 226. Invert Binary Tree
- LeetCode #226. Invert Binary Tree
- [LeetCode]226. Invert Binary Tree
- 距离向量选路算法
- DrawerLayout的学习(与ToolBar结合)
- java apache commons HttpClient发送get和post请求的学习整理
- java中调用matlab的函数
- Spring各jar包的作用
- Leetcode题解 226. Invert Binary Tree
- 第十六周项目 电子词典
- 一个省市县三级联动的回显(带数据库)
- Git II: 操作远程Repository基础
- Android中Activity跳转过程中的反向传值
- APP数据分析的常用指标
- 不一样的webService 简单实例
- java中Date类和Calendar类对日期的操作
- Android之粗仿微信6.0——微信6.0的欢迎界面