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