226. Invert Binary Tree
来源:互联网 发布:网络贷款 编辑:程序博客网 时间:2024/06/05 07:57
1、题目描述
输入一棵二叉树,返回它的镜面对称。
2、思路
二叉树的左子树为右子树的镜面对称,右子树为左子树的镜面对称。
3、代码
TreeNode* invertTree(TreeNode* root) { if(!root) return NULL; TreeNode* l = root->left; root->left = invertTree(root->right); root->right = invertTree(l); 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
- Java8之方法引用
- 输出一个三角形
- 模拟退火算法——自我总结
- 数据结构实验之排序六:希尔排序
- 图像处理入门教程
- 226. Invert Binary Tree
- 关于数据库触发器的个人理解/注解
- 记录下找BUG的方法
- js 页面之间的跳转、传参以及返回上一页
- 使用Github建立个人博客
- Cassandra Shell命令
- rehsarper使用方式
- 习题7.2
- 分支中if语句