Subsets
Given an integer array nums of unique elements, return all possible subsets (the power set).
The solution set must not contain duplicate subsets.
You may return the subsets in any order.
Example 1
Input
nums = [1, 2, 3]
Output
[
[],
[1],
[2],
[1, 2],
[3],
[1, 3],
[2, 3],
[1, 2, 3]
]Explanation
For three elements, every element can either be:
- Included in the subset
- Not included in the subset
Therefore, the total number of subsets is:
2³ = 8
Example 2
Input
nums = [0]
Output
[
[],
[0]
]Explanation
The array contains one element, so there are two possible subsets:
[]
[0]
Constraints
Hints:
Hint 1
For every element, there are two choices:
- Include it.
- Exclude it.
Hint 2
Use backtracking to explore both choices.
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Aug 26, 2026
Last updated
Aug 26, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output