Skip to content

Commit 8338a00

Browse files
Added solution
1 parent 1196396 commit 8338a00

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

symmetric_tree.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,26 @@ class Solution {
2929

3030
return helper(root->left, root->right);
3131
}
32-
};
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+
return True
53+
54+
*/

0 commit comments

Comments
 (0)