Last active
November 26, 2019 13:28
-
-
Save MaxXxiMast/d3bad021172d78eab1c5568e901fa4bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const superSet = arr => { | |
var result = []; | |
result.push([]) | |
arr.forEach(val => { | |
let length = result.length; | |
let i = 0; | |
while(i < length){ | |
let newAr = result[i].slice(0); | |
newAr.push(val); | |
result.push(newAr); | |
i++; | |
} | |
}); | |
return result; | |
} | |
const setArr = [1,2,3] | |
const superSetArr = superSet(setArr); //[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment