ntree.aiSubsets
Subsets
mediumsolvedattempted
You are given an array of distinct integers nums.
Return all possible subsets of it, including the empty one. The answer may be returned in any order.
Example 1:
Input: nums = [2, 5, 9]
Output: [[], [2], [5], [2, 5], [9], [2, 9], [5, 9], [2, 5, 9]]
Example 2:
Input: nums = [7]
Output: [[], [7]]
Constraints:
1 <= length of nums <= 10-10 <= nums[i] <= 10- All the elements of
numsare different
def subsets(nums: list[int]) -> list[list[int]]: pass Press Visualise to step through your code.