mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Update trie_preorder.py
This commit is contained in:
parent
728b441734
commit
4e895726bd
@ -11,6 +11,7 @@ def preorder(root: 'Node'):
|
|||||||
stack, result = [root, ], []
|
stack, result = [root, ], []
|
||||||
|
|
||||||
while stack:
|
while stack:
|
||||||
|
|
||||||
node = stack.pop()
|
node = stack.pop()
|
||||||
result.append(node.val)
|
result.append(node.val)
|
||||||
stack.extend(node.children[::-1])
|
stack.extend(node.children[::-1])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user