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 2db9469 + 3e0ef73 commit 0f6c161Copy full SHA for 0f6c161
2018.12.4-leetcode101/GatesMa.md
@@ -0,0 +1,23 @@
1
+# c++
2
+```cpp
3
+/**
4
+ * Definition for a binary tree node.
5
+ * struct TreeNode {
6
+ * int val;
7
+ * TreeNode *left;
8
+ * TreeNode *right;
9
+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
10
+ * };
11
+ */
12
+class Solution {
13
+public:
14
+ bool isSymmetric(TreeNode* root) {
15
+ return isMirror(root, root);
16
+ }
17
+ bool isMirror(TreeNode *t1, TreeNode *t2){
18
+ if(t1 == NULL && t2 == NULL) return true;
19
+ if(t1 == NULL || t2 == NULL) return false;
20
+ return (t1->val == t2->val) && isMirror(t1->left, t2->right) && isMirror(t1->right, t2->left);
21
22
+};
23
+```
0 commit comments