Published at March 25, 2019 · 1 min read
Subsets Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Example: Input: nums = [1,2,3] Output: [ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], [] ] 给出一组不重复的整数,返回所有子集 what is power set 回溯解法(DFS) 回溯算法三要素 选择 可以作出哪些选择 约束 不能做哪些选择 目标 最终要达成的目标 class Solution: def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ res = [] self....