feat: Added 50 Pow(x,n) for nodejs
- feat: Added using recursion for permuatation problem example in nodejs
This commit is contained in:
18
rec-permute/nodejs/index.js
Normal file
18
rec-permute/nodejs/index.js
Normal 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);
|
Reference in New Issue
Block a user