LeetCode(力扣)78. 子集Python

LeetCode78. 子集

题目链接

https://leetcode.cn/problems/subsets/description/

代码

python 复制代码
class Solution:
    def subsets(self, nums: List[int]) -> List[List[int]]:
        result = []
        self.backtracking(nums, result, 0, [])
        return result

    def backtracking(self, nums, result, index, path):
        result.append(path[:])

        for i in range(index, len(nums)):
            path.append(nums[i])
            self.backtracking(nums, result, i + 1, path)
            path.pop()
相关推荐
何以解忧,唯有..6 分钟前
Go语言循环语句详解:for、range与循环控制
开发语言·算法·golang
闵孚龙34 分钟前
《PyTorch 深度修炼》Dataset 和 DataLoader:数据如何喂给模型
人工智能·pytorch·python
goldenrolan40 分钟前
A公司物料替代测试系统 v1.7:从需求到 exe/apk 的 AI 辅助全链路实践
android·自动化测试·软件测试·python·ai
想吃火锅10051 小时前
【leetcode】88.合并两个有序数组js
算法
菜板春1 小时前
jupyter入门-手册-特征探索
python·jupyter
Metaphor6921 小时前
使用 Python 将 PDF 转换为 HTML
python·pdf·html
极光代码工作室1 小时前
基于数据仓库的电商数据分析平台
大数据·hadoop·python·spark·数据可视化
开发小能手-roy1 小时前
StringBuilder vs StringBuffer:2024年还需要线程安全字符串吗?
开发语言·python·安全
生成论实验室1 小时前
机器人:一个自主运动的系统
人工智能·算法·语言模型·机器人·自动驾驶·agi·安全架构
Qres8212 小时前
算法复键——树状数组
数据结构·算法