Invert Binary Tree
来源:互联网 发布:大连seo服务公司 编辑:程序博客网 时间:2024/06/07 01:12
方法一:
struct TreeNode* invertTree(struct TreeNode* root) { struct TreeNode* temp;//别忘记struct if(root==NULL) return root; temp=root->left; root->left=invertTree(root->right); root->right=invertTree(temp); return root;}
方法二:
TreeNode* invertTree(TreeNode* root) { if(!root) return NULL; swap(root->left, root->right); root->left = invertTree(root->left); root->right = invertTree(root->right); return root;}
0 0
- [leetcode] Invert Binary Tree
- [LeetCode]Invert Binary Tree
- Invert Binary Tree
- leetcode:Invert Binary Tree
- Invert Binary Tree
- LeetCode Invert Binary Tree
- 226Invert Binary Tree
- LeetCode | Invert Binary Tree
- leetcode--Invert Binary Tree
- [leetcode] Invert Binary Tree
- [LeetCode] Invert Binary Tree
- LeetCode Invert Binary Tree
- Invert Binary Tree
- leetcode : Invert Binary Tree
- 226Invert Binary Tree
- Invert Binary Tree
- [LeetCode] Invert Binary Tree
- [Leetcode]Invert Binary Tree
- 3、算术运算符的使用(0106)
- 递归、递推(斐波那契数列)
- MySQL 查看编码 排序规则
- pat 1008
- 【网站高性能 6】----大型网站架构演化知多少(一)
- Invert Binary Tree
- CoordinatorLayout使用详解
- mysql浮点数decimal、float、double默认进位方式
- 读书笔记第一章第五节 1.5连接MySQL
- 【JQuery】实例--单击文本,文本消失
- 4、计算键盘输入会员卡号之和
- Golang中结构体转byte数组
- PHP实现:一致性HASH算法
- 在php中调用接口以及编写接口