Generate every possible subset of a given list of distinct integers.
Given a list of distinct integers, return the power set: every subset that can be formed from the list, including the empty subset and the full set.
A subset may be returned in any order, but each subset should contain elements in the same relative order as they appear in the input.
Produce all subsets without duplicates.
nums of distinct integers.nums.length = n.nums.Example 1
Input
nums = [1,2,3]
Output
[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
Explanation
Each element can either be present or absent, producing subsets.
Example 2
Input
nums = [0]
Output
[[],[0]]
Explanation
There are two subsets: the empty subset and the subset containing the single element.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.