MCPcopy
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / mirrorPreOrder

Method mirrorPreOrder

Target Offer/对称的二叉树.py:53–71  ·  view source on GitHub ↗
(self, pRoot)

Source from the content-addressed store, hash-verified

51 return output
52
53 def mirrorPreOrder(self, pRoot):
54 if pRoot == None:
55 return [None]
56 treeStack = []
57 output = []
58 pNode = pRoot
59 while pNode or len(treeStack) > 0:
60 while pNode:
61 treeStack.append(pNode)
62 output.append(pNode.val)
63 pNode = pNode.right
64 if not pNode:
65 output.append(None)
66 if len(treeStack):
67 pNode = treeStack.pop()
68 pNode = pNode.left
69 if not pNode:
70 output.append(None)
71 return output
72
73pNode1 = TreeNode(8)
74pNode2 = TreeNode(6)

Callers 1

isSymmetricalMethod · 0.95

Calls 1

popMethod · 0.45

Tested by

no test coverage detected