Review Note
Last Update: 07/03/2024 02:06 AM
Current Deck: LeetCode
Published
Fields:
Front
78. Subsets
- Given an integer array
nums
of unique elements, return all possible subsets (A subset of an array is a selection of elements (possibly none) of the array.) (the power set). - The solution set must not contain duplicate subsets. Return the solution in any order.
Back
class Solution:
def subsets(self, nums):
def dfs(i, subset):
res.append(subset)
for j in range(i, len(nums)):
dfs(j + 1, subset + [nums[j]])
res = []
dfs(0, [])
Tags:
Suggested Changes:
Deck Changes (Suggestion to move the Note to the following Deck):
Field Changes:
Tag Changes: