1
class Solution {
2
public:
3
bool mirror(TreeNode *root1, TreeNode *root2) {
4
if (root1 == NULL and root2 == NULL) return true;
5
if (root1 == NULL or root2 == NULL) return false;
6

7
if (root1->val != root2->val) return false;
8

9
return mirror(root1->left, root2->right) and mirror(root1->right, root2->left);
10
}
11

12
bool isSymmetric(TreeNode *root) {
13
if (root == NULL) return true;
14

15
return mirror(root->left, root->right);
16
}
17
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0