Power Set
MediumThe power set is a set of all possible subsets of the input set.
For example, if you're given the following input set:
{2, 4, 6}
The power set would be:
{ {}, {2}, {4}, {6}, {2, 4}, {2, 6}, {4, 6} }
Write a function that returns the power set of the input set.
Note that by definition, a set has unique elements.
However for this exercise, your function will be passsed a list of numbers.
The function should return a list of all the subsets, each represented by lists.
Solution
8 Essential Recursion & Dynamic Programming Coding Interview Problems
Master Recursion & Dynamic Programming by trying the coding challenges below.
- 1.FibonacciEasy
- 2.Unique pathsMedium
- 3.KnapsackMedium
- 4.Subset sumMedium
- 5.Power setMedium
- 6.Coin changeMedium
- 7.Word breakHard
- 8.Longest common subsequenceHard