Given a set of distinct integers S, return all possible subsets.

Problem Note

  • The solution set must not contain duplicate subsets.
  • The set is not necessarily sorted.
  • You can return all subsets in any order(not necessarily sorted).
  • The total number of subsets of a given set of size n is equal to 2^n.

Example 1

Input: S[] = [1,2,3]
Output:
[
  [],
  [1],
  [1,2],
  [1,2,3],
  [1,3],
  [2],
  [2,3],
  [3]
]