python 类中的递归函数使用
📅 2026/7/28 18:21:37
👁️ 阅读次数
📝 编程学习
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)): node=root.children[i] order+=self.preorder(node) return order类中的函数递归调用,要使用self.preorder()调用
编程学习
技术分享
实战经验