Subsets

Question (LC.78)

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

The solution set must not contain duplicate subsets. Input does not contain duplicates.

Example

Input: nums = [1, 2, 3]
Return: 
[
  [3],
  [1],
  [2],
  [1,2,3],
  [1,3],
  [2,3],
  [1,2],
  []
]

Analysis

dfs tree approach

first recurve vs for loop

array switch approach

why the first way is less efficient

iterative approach

Follow Up Question (LC.90)

Follow up about duplicate inputs

results matching ""

    No results matching ""