Math Fundamentals18 sections · 814 units
Open in Course

Problem - Subsets

All possible subsets

Given an integer array with distinct values, return all possible subsets (the power set). The solution set must not contain duplicate subsets.

For example, if nums =[1,2,3]= [1, 2, 3], you return [[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]][[], [1], [2], [3], [1,2], [1,3], [2,3], [1,2,3]]. Notice the empty set is included.

This is simpler than the combinations problem because you do not have a fixed size. Every combination of any length is valid.