Update trie_postorder.py

This commit is contained in:
bt3gl 2023-08-08 17:01:53 -07:00 committed by GitHub
parent a97c06f579
commit 728b441734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)