Subsets

Medium · Backtracking · Array · Backtracking · Bit Manipulation

Problem

Given an array nums of distinct integers, return all possible subsets (the power set), in any order and without duplicates.

Examples

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

All 2³ = 8 subsets.

Input: nums = [0]
Output: [[],[0]]

Constraints

Approaches

Related problems

Start free on Cariara · Coding problems · System design studio

Starting Python
No results yet.

          
↑↓ move ↵ open esc close

Labs

Loading labs…

Run with your own input

Starting Python

Loading Python…