"""
# Definition for a Node.
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
"""
class Solution(object):
def preorder(self, root):
"""
:type root: Node
:rtype: List[int]
"""if root is None:
return []
if root.children is None:
return [root.val]
L = [root.val]
for child in root.children:
L += self.preorder(child)
return L#有时间补一下迭代法解答
leetcode - 589 - N叉树的前序遍历
猜你喜欢
转载自blog.csdn.net/hustwayne/article/details/83626791
今日推荐
周排行