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.preor…
2026/7/28 17:56:11