We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ee79193 + dc858ab commit 175acfcCopy full SHA for 175acfc
2018.12.4-leetcode101/Sagittarius.md
@@ -0,0 +1,35 @@
1
+```
2
+/**
3
+ * Definition for a binary tree node.
4
+ * struct TreeNode {
5
+ * int val;
6
+ * TreeNode *left;
7
+ * TreeNode *right;
8
+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
9
+ * };
10
+ */
11
+bool isSymmetric1(TreeNode* r1,TreeNode* r2)
12
+{
13
+ if(!r1&&!r2)
14
+ return true;
15
+ else if((r1&&!r2)||(!r1&&r2))
16
+ return false;
17
+ else
18
+ {
19
+ if(r1->val!=r2->val)
20
21
22
+ return isSymmetric1(r1->left,r2->right)&&isSymmetric1(r1->right,r2->left);
23
+ }
24
+
25
+}
26
+class Solution {
27
+public:
28
+ bool isSymmetric(TreeNode* root) {
29
+ if(!root)
30
31
32
+ return isSymmetric1(root->left,root->right);
33
34
+};
35
0 commit comments