Skip to content

Commit 3ee6d5f

Browse files
author
Chris Wu
committed
no message
1 parent fa67f08 commit 3ee6d5f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Post-order traversal means that: if there is a left node, visit it; then if there is right node, visit it; visit the current node.
3+
In-order: Left->Current->Right
4+
Pre-order: Current->Left->Right
5+
Post-order: Left->Right->Current
6+
"""
7+
class Solution(object):
8+
def postorder(self, root):
9+
def helper(node):
10+
if not node: return
11+
for child in node.children:
12+
helper(child)
13+
opt.append(node.val)
14+
opt = []
15+
helper(root)
16+
return opt

0 commit comments

Comments
 (0)