```
class Solution {
public:
bool isSymmetric(TreeNode* l, TreeNode* r) {
if (l == NULL || r == NULL) return l==r;
return (l->val == r->val) && isSymmetric(l->left, r->right) && isSymmetric(l->right, r->left);
}
bool isSymmetric(TreeNode* root) {
return root == NULL || isSymmetric(root->left, root->right);
}
};
```