mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
22 lines
391 B
Python
22 lines
391 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
# author: bt3gl
|
|
|
|
|
|
def postorder(self, root: 'Node') -> List[int]:
|
|
|
|
if root is None:
|
|
return []
|
|
|
|
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)
|
|
|
|
return result[::-1]
|
|
|