Created
June 26, 2018 20:57
-
-
Save pinkmomo027/57407d56b982f9698e9edb04d9342b4d to your computer and use it in GitHub Desktop.
permutation
This file contains hidden or 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 travel(temp, level) { | |
| if (count.every(element => element == 0) ) { | |
| result.push(temp.join('')); | |
| return; | |
| } | |
| for (let i = 0; i < count.length; i++) { | |
| if (count[i] > 0) { | |
| count[i]--; | |
| temp[level] = chars[i]; | |
| travel(temp, level+1); | |
| count[i]++; | |
| } | |
| } | |
| } | |
| travel(temp, level=0); | |
| console.log(result); |
Author
pinkmomo027
commented
Jun 26, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment