多彩编程 多彩编程MZPH · CODE BLOG
ARTICLE DETAIL

文章详情

深耕前端与后端开发技术的一线实战笔记与踩坑复盘。

python 类中的递归函数使用

python 类中的递归函数使用 n叉数的前序遍历class Solution: def preorder(self, root: Node) - List[int]: order[] if root!None: order.append(root.val) for i in range(len(root.children)): noderoot.children[i] orderself.preorder(node) return order类中的函数递归调用要使用self.preorder()调用
返回列表