Skip to content

Latest commit

 

History

History
17 lines (8 loc) · 486 Bytes

File metadata and controls

17 lines (8 loc) · 486 Bytes

Powerset

Problem Statement

Write a function that takes in an array of unique integers and returns its powerset. The powerset P(X) of a set X is the set of all subsets of X. For example, the powerset of [1,2] is [[], [1], [2], [1,2]]. Note that the sets in the powerset do not need to be in any particular order.

Sample input: [1, 2, 3]

Sample output: [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]

Solution

Check this Python code.