mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 12:16:14 -04:00
Update trie_postorder.py
This commit is contained in:
parent
a97c06f579
commit
728b441734
@ -3,7 +3,7 @@
|
||||
# author: bt3gl
|
||||
|
||||
|
||||
def postorder(self, root: 'Node') -> List[int]:
|
||||
def postorder(self, root: 'Node'):
|
||||
|
||||
if root is None:
|
||||
return []
|
||||
@ -11,9 +11,12 @@ def postorder(self, root: 'Node') -> List[int]:
|
||||
stack, result = [root, ], []
|
||||
|
||||
while stack:
|
||||
|
||||
node = stack.pop()
|
||||
|
||||
if node is not None:
|
||||
result.append(node.val)
|
||||
|
||||
for c in node.children:
|
||||
stack.append(c)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user