Created
October 22, 2017 03:05
-
-
Save rohit012/8480faa4585c30668d8b58e71a30ade8 to your computer and use it in GitHub Desktop.
Combinations of string characters all unique
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
var combinations = function(str) { | |
var arr = str.split(''); | |
for( var i=0; i< arr.length; i++){ | |
genComb(arr, i+1); | |
} | |
} | |
function genComb(arr, length, str, index) { | |
str = str || ''; | |
index = index || 0; | |
if(str.length === length) { | |
console.log(str, length); | |
return; | |
} | |
for(i=index; i<arr.length; i++){ | |
genLenPermu(arr, length, str+arr[i], i+1); | |
} | |
} | |
combinations('aaa'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment