-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution_plain.cc
More file actions
44 lines (36 loc) · 868 Bytes
/
Copy pathsolution_plain.cc
File metadata and controls
44 lines (36 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*************************************************************************
> File Name: solution_template.cc
> Author: MarkWoo
> Mail:wcgwuxinwei@gmail.com
> Created Time: Tue 10 May 2016 11:21:46 PM CST
************************************************************************/
#include <iostream>
#include <string>
#include <vector>
using namespace std;
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 root;
if (root->left != NULL)
invertTree(root->left);
if (root->right != NULL)
invertTree(root->right);
TreeNode *tmp = root->right;
root->right = root->left;
root->left = tmp;
return root;
}
};
int main(void)
{
Solution solution;
return 0;
}