http://oj.leetcode.com/problems/symmetric-tree/
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
bool isEqual(TreeNode *left, TreeNode *right){
int cnt=0;
if(left==NULL) cnt++;
if(right==NULL) cnt++;
if(cnt==2) return true;
if(cnt==1) return false;
if(left->val!=right->val) return false;
if(isEqual(left->left,right->right)&&isEqual(left->right,right->left)) return true;
else return false;
}
bool isSymmetric(TreeNode *root) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(root==NULL) return true;
else return isEqual(root->left,root->right);
}
};