[Leetcode] Invert Binary Tree
来源:互联网 发布:北京美工培训 便宜 编辑:程序博客网 时间:2024/06/06 07:22
Invert a binary tree.
4 / \ 2 7 / \ / \1 3 6 9to
4 / \ 7 2 / \ / \9 6 3 1最先想到的当然是递归的思想,将两个左右指针进行互换:
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */struct TreeNode* invertTree(struct TreeNode* root) { if (!root) return NULL; root->left = invertTree(root->left); root->right = invertTree(root->right); struct TreeNode *tmp = root->left; root->left = root->right; root->right = tmp; return root;}
0 0
- [leetcode] Invert Binary Tree
- [LeetCode]Invert Binary Tree
- leetcode:Invert Binary Tree
- LeetCode Invert Binary Tree
- LeetCode | Invert Binary Tree
- leetcode--Invert Binary Tree
- [leetcode] Invert Binary Tree
- [LeetCode] Invert Binary Tree
- LeetCode Invert Binary Tree
- leetcode : Invert Binary Tree
- [LeetCode] Invert Binary Tree
- [Leetcode]Invert Binary Tree
- LeetCode: Invert Binary Tree
- LeetCode Invert Binary Tree
- leetcode: Invert Binary Tree
- LeetCode Invert Binary Tree
- LeetCode || Invert Binary Tree
- LeetCode:Invert Binary Tree
- matlab数字图像的傅立叶变换实验
- 群聊这么复杂,该怎么玩转?
- YCSB基础知识及HBase性能测试
- MySQL Schema设计(四)一个MySQL里的JQuery:common_schema
- Sublime Text3下配置SublimeLinter进行PHP代码检查
- [Leetcode] Invert Binary Tree
- SpringMVC+Mybatis架构下的增删查改
- linux远程挂载磁盘
- 第十一周项目1-验证算法(中序线索化二叉树)
- XMind 8 新版本,新的窗口视图工具
- PING ip 工具类
- 应用程序接口集成权威指南[电子书]
- Swiift3.0 UITextFiled键盘返回事件,点击其他区域,键盘收起,停止编辑;UITableViewCell取消选中行,以及系统默认的线的长短调整
- Android游戏开发属性