/**
* Created by cshao on 12/23/14.
*/
function getPermutation(arr) {
if (arr.length == 1) {
return [arr];
}
var permutation = [];
for (var i=0; i
var firstEle = arr[i];
var arrClone = arr.slice(0);
arrClone.splice(i, 1);
var childPermutation = getPermutation(arrClone);
for (var j=0; j
childPermutation[j].unshift(firstEle);
}
permutation = permutation.concat(childPermutation);
}
return permutation;
}
var permutation = getPermutation(['a','b','c']);
console.dir(permutation);