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