"""
# Definition for a Node.
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
"""
class Solution(object):
def postorder(self, root):
"""
:type root: Node
:rtype: List[int]
"""
if root is None:
return []
if root.children is None:
return [root.val]
L = []
for child in root.children:
L += self.postorder(child)
L += [root.val]
return L
leetcode - 590 - N叉树的后序遍历
最新推荐文章于 2021-07-19 11:43:22 发布