‹ DS&A interview · Socratic
DSA · Backtracking · #18

Subsets

Module 21 · difficulty 3/5·30:00starts on first keystroke

Given an integer array `nums` of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the subsets in any order.

Examples
  • nums = [1,2,3] [[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]
  • nums = [0] [[],[0]]
  • nums = [] [[]]
Constraints
  • · 0 <= nums.length <= 10
  • · -10 <= nums[i] <= 10
  • · All numbers of nums are unique.
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.