Skip to content

Commit 0733efc

Browse files
author
Luciano Medeiros Marcelino
committed
Adjust file to keep consistency
The whole repository uses 2 spaces for indentation and does not use console.log anywhere. Also the repo standard is to use dash to separate words in the folders names.
1 parent e7f1166 commit 0733efc

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// GET PERMUTATION OF A GIVEN STRING
2+
3+
let getPermutation = (str) => {
4+
if (str.length == 1) {
5+
let array = [];
6+
array.push(str);
7+
return array;
8+
}
9+
10+
let currentCharacter = str.charAt(0);
11+
let restOfString = str.substring(1);
12+
let result = [];
13+
let returnResult = getPermutation(restOfString);
14+
15+
for (j = 0; j < returnResult.length; j++) {
16+
for (i = 0; i <= returnResult[j].length; i++) {
17+
let value = returnResult[j].substring(0, i) + currentCharacter + returnResult[j].substring(i);
18+
result.push(value);
19+
}
20+
}
21+
22+
return result;
23+
}

0 commit comments

Comments
 (0)