LeetCode-226 Invert Binary Tree
来源:互联网 发布:网络维护员的技能 编辑:程序博客网 时间:2024/06/07 22:00
https://leetcode.com/problems/invert-binary-tree/
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.* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode* invertTree(TreeNode* root) {
if(root == NULL)
return NULL;
TreeNode *ptr = root->left;
root->left = root->right;
root->right = ptr;
invertTree(root->left);
invertTree(root->right);
return root;
}
};
0 0
- Leetcode[226]-Invert Binary Tree
- LeetCode 226 Invert Binary Tree
- Invert Binary Tree - LeetCode 226
- 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 226Invert 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
- 巧用box-shadow实现布局区域间隔变色
- Elasticsearch学习(一)
- VirtualBox 4.3.12安装Ubuntu已安装增强工具后,仍然不能调分辨率
- 视频聊天SDK
- 知识点
- LeetCode-226 Invert Binary Tree
- css 伪类选择器 :nth-child(n) 与:nth-of-type(n)的区别
- Android中的性能优化
- CSS学习6(元素框)
- KSDK2.0 + Pins Tool 体验
- 读取txt文件
- UVA 1625 Color Length
- linux之NTP时间同步服务介绍
- swift初探