Dodomeki
Sign in

42. Possible Subsets

Easy

Given a list nums with no duplicate values, return all of its subsets, including the empty set and the list itself. The order of the subsets and of the values inside each subset does not matter.

Example 1
Input: nums = [2, 5]
Output: [[], [2], [5], [2, 5]]
Example 2
Input: nums = [-1, 3, 4]
Output: [[], [-1], [3], [4], [-1, 3], [-1, 4], [3, 4], [-1, 3, 4]]
Constraints
  • 0 <= nums.length <= 12
  • -20 <= nums[i] <= 20
  • Todos os valores de nums são distintos.
BacktrackingArrays
Caso 1
nums =
[2,5]
Expected =
[[],[5],[2],[2,5]]
Caso 2
nums =
[-1,3,4]
Expected =
[[],[4],[3],[3,4],[-1],[-1,4],[-1,3],[-1,3,4]]

Run checks these 2 cases. Submit runs all 6, including hidden ones.