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