You get an array nums of distinct integers. Return every subset of it: every group you can form by keeping some of its numbers and leaving out the rest. Keeping none of them gives the empty subset [], and keeping all of them gives the whole array.
An array of n numbers has 2ⁿ subsets, because each number is either in or out. List each subset exactly once. Two subsets are the same when they hold the same numbers, so [4,7] and [7,4] count as one.
You may return the subsets in any order, and the numbers inside each subset in any order too.
Three numbers, each in or out, make 2³ = 8 subsets, from the empty one up to all three.
Four subsets: neither number, either one alone, or both.
A single number is either left out or kept.
Constraints
1 <= nums.length <= 10-10 <= nums[i] <= 10nums are all different.Each number is either in a subset or out of it, so n numbers give 2ⁿ subsets. Build them one number at a time.