MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / isSymmetric2

Method isSymmetric2

leetcode/101. Symmetric Tree.py:37–46  ·  view source on GitHub ↗
(self, root)

Source from the content-addressed store, hash-verified

35
36 #iterative(BFS)
37 def isSymmetric2(self, root):
38 if root:
39 now = [root]
40 while now:
41 vals = [i.val if i else None for i in now]
42 if list(reversed(vals)) != vals:
43 return False
44 else:
45 now = [j for i in now if i for j in (i.left, i.right)]
46 return True
47 # modify iterative(BFS)
48 def isSymmetric_2(self, root):
49 if root:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected