N-ary Tree Postorder Traversal LeetCode solution in Python

1
class Solution(object):
2
def postorder(self, root):
3
"""
4
:type root: Node
5
:rtype: List[int]
6
"""
7
res = []
8

9
def bfs(root):
10
if root:
11
for child in root.children:
12
bfs(child)
13

14
res.append(root.val)
15

16
bfs(root)
17

18
return res

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0