Created
August 11, 2020 08:19
-
-
Save spiterman/059600437f6e0c6f559a212266bf3062 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
function PowerSet(str) { | |
let result = [] | |
function constructSubSet(subSet, index) { | |
if(index >= str.length) { | |
result.push(subSet) | |
return | |
} | |
constructSubSet(subSet, index + 1) | |
constructSubSet(subSet + str[index], index + 1) | |
} | |
constructSubSet("", 0) | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment