###### 101. Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).

For example, this binary tree [1,2,2,3,4,4,3] is symmetric:

    1
/ \
2   2
/ \ / \
3  4 4  3


But the following [1,2,2,null,3,null,3] is not:

    1
/ \
2   2
\   \
3    3


Note:
Bonus points if you could solve it both recursively and iteratively.

/**
* 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:
bool isSymmetric(TreeNode* root) {
if (!root)
return true;
else
return testSymmetric(root->left,root->right);
}
bool testSymmetric(TreeNode* left,TreeNode* right)
{
if (!left&&!right)
return true;
else if (!left&&right)  return false;
else if (left&&!right)  return false;
else if (left&&right&&left->val!=right->val) return false;
else return testSymmetric(left->left,right->right)&&testSymmetric(left->right,right->left);
}
};

#### 【LeetCode】101. Symmetric Tree 解题报告

2016-05-30 23:06:35

#### LeetCode(101)Symmetric Tree

2014-01-17 06:48:54

#### 101. Symmetric Tree [easy] (Python)

2016-06-03 15:53:34

#### 【LeetCode-面试算法经典-Java实现】【101-Symmetric Tree（对称树）】

2015-08-07 07:29:25

#### 【leetcode c++】101 Symmetric Tree

2015-07-27 14:39:02

#### [leetcode] 101. Symmetric Tree 解题报告

2015-12-24 15:30:34

#### leetcode_question_101 Symmetric Tree

2013-09-23 00:36:59

#### leetcode 101. Symmetric Tree（C语言，二叉树，递归，判对称性）30

2017-10-12 13:28:11

#### 101. Symmetric Tree Leetcode Python

2015-01-30 07:28:30

#### Leetcode 101. Symmetric Tree 验证树的对称性 解题报告

2016-09-04 15:48:23

## 不良信息举报

101. Symmetric Tree