Power Set of Distinct Values
Return every subset of a list of distinct integers.
The problem
Implement Solution.subsets(nums). The integers in nums are all different. Return every subset of nums, including the empty subset and nums itself. For example, [1, 2] has the subsets [], [1], [2] and [1, 2]. The subsets can be in any order, and so can the values inside each subset. If nums is empty, return [[]]. Constraints: 0 to 10 distinct integers, each from -10 to 10.
Starter code
class Solution:
def subsets(self, nums):
passPublic examples
nums = [1, 2, 3]gives[[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]nums = [0, 1]gives[[], [0], [1], [0, 1]]nums = [10]gives[[], [10]]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
