###### 226. Invert Binary Tree

/**
* 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) {
TreeNode* temp;
if(root == NULL)
return NULL;
else
{
TreeNode* leftptr=invertTree(root-> left);
TreeNode* rightptr=invertTree(root-> right);
temp=root->left;
root->left=root->right;
root->right=temp;
return root;
}

}
};

/**
* 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) {
TreeNode* temp;
if(root == NULL)
return NULL;
else
{
TreeNode* leftptr=invertTree(root-> left);
TreeNode* rightptr=invertTree(root-> right);
temp=<span style="font-family: Arial, Helvetica, sans-serif;">leftptr</span><span style="font-family: Arial, Helvetica, sans-serif;">;</span>
leftptr=rightptr;
rightptr=temp;
return root;
}

}
};

#### 【LeetCode】226. Invert Binary Tree 解题报告

2016-05-29 00:18:13

#### 226. Invert Binary Tree [easy] (Python)

2016-05-12 14:36:34

#### leetcode（226）—— Invert Binary Tree（Python/C++）

2016-04-15 14:57:52

#### leetcode 226 Invert Binary Tree 翻转二叉树

2015-06-23 23:53:58

#### Leetcode 226: Invert Binary Tree(二叉树反转 递归、非递归实现)

2015-06-13 14:41:43

#### 226. Invert Binary Tree的C++解法

2017-04-06 10:37:37

#### leetcode解题之226# Invert Binary Tree Java版 (交换树的左右子树）

2017-03-19 07:10:55

#### 1102. Invert a Binary Tree (25)-PAT甲级真题

2016-08-10 20:04:01

#### 226. Invert Binary Tree *

2016-11-29 17:52:01

#### 【PAT】1102. Invert a Binary Tree (25)

2015-10-24 19:19:54

## 不良信息举报

226. Invert Binary Tree