← 返回题库
中级

路径总和 II

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve(____):
    result = []
    def dfs(____):
        if not node:
            return
        path.append(____)
        if not node.left and not node.right and remaining == node.val:
            result.append(____)
        dfs(____)
        dfs(____)
        path.pop()
    dfs(____)
    return result

示例

输入
root=[5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum=22
期望输出
[[5,4,11,2],[5,8,4,5]]
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码