Problem
You get an array nums of different integers. Return all the subsets of nums.
A subset is a group of zero or more items from nums. The empty group and the whole array are also subsets. The result must not contain the same subset two times.
You can return the subsets in any order. The items inside each subset can also be in any order.
Example 1
- Input:
- nums = [4,7]
- Output:
- [[],[4],[7],[4,7]]
Example 2
- Input:
- nums = [5,-1,2]
- Output:
- [[],[5],[-1],[2],[5,-1],[5,2],[-1,2],[5,-1,2]]
- Explanation:
- An array with 3 items has
2^3 = 8subsets.
Example 3
- Input:
- nums = [0]
- Output:
- [[],[0]]
Constraints
- 1 <= nums.length <= 10
- -10 <= nums[i] <= 10
- All the numbers in nums are different.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Beautiful Arrangement
Coding · Array · Backtracking · Bit Manipulation
- Optimal Account Balancing
Coding · Array · Backtracking · Bit Manipulation
- Maximum Bitwise AND After Increment Operations
Coding · Array · Bit Manipulation · Greedy
- Maximum Path Quality of a Graph
Coding · Array · Backtracking · Graph Theory
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 4 records
Amazon
Leetcode 78. Subsets
Reported Feb 3, 2025 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceDocusign
Leetcode 78. Subsets
Reported Jun 24, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 78. Subsets
Reported Sep 19, 2025 · 4 source reports
MID_LEVEL, SENIOR
Source snapshot: Nov 12, 2026
View sourceMicrosoft
Leetcode 78. Subsets
Reported Feb 14, 2026 · 2 source reports
MID_LEVEL
Source snapshot: Nov 12, 2026
View source