Skip to content

Instantly share code, notes, and snippets.

@spiterman
Created August 11, 2020 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spiterman/059600437f6e0c6f559a212266bf3062 to your computer and use it in GitHub Desktop.
Save spiterman/059600437f6e0c6f559a212266bf3062 to your computer and use it in GitHub Desktop.
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