Medium · Backtracking

Subsets

You are given a list of distinct whole numbers. Return every subset of it: every way of choosing some, none or all of the numbers.

  • Every number appears once.
  • The empty subset and the full list are both subsets.
  • The subsets can be in any order, and so can the numbers inside one.
nums = [1, 2, 3]

→ [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]
Record your take

No one has solved it yet.