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.
1 parent 1196396 commit 8338a00Copy full SHA for 8338a00
symmetric_tree.cpp
@@ -29,4 +29,26 @@ class Solution {
29
30
return helper(root->left, root->right);
31
}
32
-};
+};
33
+
34
+/*
35
+def isSymmetric(self, root: TreeNode) -> bool:
36
37
+ if not root:
38
+ return True
39
40
+ stack = [(root.left, root.right)]
41
42
+ while stack:
43
+ c = stack.pop()
44
+ l, r = c[0], c[1]
45
46
+ if not l and not r:
47
+ continue
48
+ if (l and not r) or (r and not l) or (l.val != r.val):
49
+ return False
50
+ stack.append((l.right, r.left))
51
+ stack.append((l.left, r.right))
52
53
54
+*/
0 commit comments