Subsets
Return all subsets of a list of distinct integers, including the empty subset. Each subset and the result may be ordered arbitrarily.
Example 1
nums = [2,5][[],[2],[5],[2,5]]Explanation
Each of 2 and 5 may be included or excluded, giving four subsets.
Example 2
nums = [][[]]Explanation
Empty input has exactly one subset: the empty subset.
Example 3
nums = [9][[],[9]]Explanation
A singleton has the empty subset and the subset containing 9.
Constraints
- 0 <= len(nums) <= 10
- Values are distinct
Function contract
subsetsArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 34 cases, on your device.
[2,5]