Subsets / Power Set

00:00
MediumRecursionBacktrackingBit Manipulation
AmazonFacebook

Generate all possible subsets (power set) of an array. Return all subsets including empty set. No duplicates.

Examples

Input → [1,2,3]
Output → [[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]
Input → [0]
Output → [[],[0]]
Input → []
Output → [[]]