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[] = [2,3,4]
Output:
[
  [],
  [2],
  [2,3],
  [2,3,4],
  [2,4],
  [3],
  [3,4],
  [4]
]
Explanation: All the subsets of the given set S is printed.