###### Invert Binary Tree

/**
* Definition for a binary tree node.
* public class TreeNode {
*     int val;
*     TreeNode left;
*     TreeNode right;
*     TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public TreeNode invertTree(TreeNode root) {
if (root == null) {
return null;
}
levelInvertTree(root);
return root;
}
private void levelInvertTree(TreeNode node) {
TreeNode temp = node.left;
node.left = node.right;
node.right = temp;

if (node.left != null) {
levelInvertTree(node.left);
}
if (node.left != null) {
levelInvertTree(node.right);
}
}
}

/**
* Definition for a binary tree node.
* public class TreeNode {
*     int val;
*     TreeNode left;
*     TreeNode right;
*     TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public TreeNode invertTree(TreeNode root) {
if (root == null) {
return null;
}
while (!queue.isEmpty()) {
TreeNode node = queue.poll();
TreeNode temp = node.left;
node.left = node.right;
node.right = temp;

if (node.left != null) {
}
if (node.right != null) {
}
}
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 翻转二叉树

2015-06-23 23:53:58

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

2016-04-15 14:57:52

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

2015-06-13 14:41:43

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

2017-04-06 10:37:37

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

2016-08-10 20:04:01

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

2015-10-24 19:19:54

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

2017-03-19 07:10:55

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

2017-10-09 15:00:02

## 不良信息举报

Invert Binary Tree