feat: Added 50 Pow(x,n) for nodejs

- feat: Added using recursion for permuatation problem example in nodejs
This commit is contained in:
Aerex
2020-01-27 20:58:15 -06:00
parent 8dae9824b3
commit cf1d656aa5
3 changed files with 115 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
const RecPermute = (soFar, rest) => {
if (rest.length === 0) {
console.log('result', soFar);
console.log('\n\n');
} else {
for (let i = 0; i < rest.length; i++) {
const remaining = rest.substring(0,i) + rest.substring(i+1);
console.log('r', remaining)
console.log('R', rest);
console.log('SF', soFar);
console.log('------');
RecPermute(soFar + rest[i], remaining);
}
}
};
x = 'abc';
RecPermute('', x);