Easy 226题 Invert Binary Tree
来源:互联网 发布:高洛峰2014版php视频 编辑:程序博客网 时间:2024/04/25 09:39
问题:
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; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: TreeNode* invertTree(TreeNode* root) { if(root) { TreeNode* tmp=root->left; root->left=root->right; root->right=tmp; invertTree(root->left); invertTree(root->right); } return root; }};
0 0
- Easy 226题 Invert Binary Tree
- Invert Binary Tree(easy)
- [Leetcode 226, Easy] Invert Binary Tree
- <LeetCode><Easy>226Invert a binary tree
- LeetCode #226 - Invert Binary Tree - Easy
- 【Leetcode-easy-226】Invert Binary Tree
- 226. Invert Binary Tree (Easy)
- 【leetcode】【Easy】【226. Invert Binary Tree】【tree】
- leetcode 226 Invert Binary Tree(难易度:Easy)
- 226. Invert Binary Tree [easy] (Python)
- Easy-题目4:226. Invert Binary Tree
- Leetcode 226. Invert Binary Tree (Easy) (cpp)
- 226. Invert Binary Tree Difficult: Easy
- LeetCode 226. Invert Binary Tree (Easy)
- 226Invert Binary Tree
- 226Invert Binary Tree
- 226 Invert Binary Tree
- 226 Invert Binary Tree
- HTTP 协议入门
- 简单分享一个轻量级自动化测试框架目录结构设计
- synchronized的4种用法
- Handler,Looper,Message,MessageQueue的关系
- TensorFlow, Keras, TensorLayer, Tflearn 比较
- Easy 226题 Invert Binary Tree
- FIR滤波器设计
- Linux驱动编程day4--实现硬件控制
- Red Hat 6.7 配置使用centos的yum源
- 【解题报告】Codeforces Round #368 (Div. 2)
- 全球参数APN工具代码集成
- 《我的RobotFramework书》1-6 变量, Variable
- maven安装配置
- SELECT单表查询