Skip to content

Commit 7ae9d44

Browse files
committed
101
1 parent 58fa0f8 commit 7ae9d44

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

101.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public:
3+
bool isSymmetric(TreeNode* root) {
4+
5+
return isSymmetric1(root,root);
6+
}
7+
8+
bool isSymmetric1(TreeNode * root1,TreeNode * root2)
9+
{
10+
if(root1==NULL && root2==NULL)
11+
{
12+
return 1;
13+
}
14+
if(root1!=NULL && root2!=NULL && root1->val==root2->val)
15+
{
16+
return isSymmetric1(root1->left,root2->right) && isSymmetric1(root1->right,root2->left);
17+
}
18+
return 0;
19+
}
20+
21+
};

0 commit comments

Comments
 (0)