LeetCode590

水题 

"""
# 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 []
        ans = []
        for child in root.children:
            ans += self.postorder(child)
        return ans+[root.val]

猜你喜欢

转载自blog.csdn.net/zuocuomiao/article/details/82181503
今日推荐