We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9e5041a commit 1e8c8f2Copy full SHA for 1e8c8f2
16_permutations/solution/permutations-solution.js
@@ -1,9 +1,6 @@
1
-const permutations = function (original, currentPermutations) {
2
- if (original.length === 1) return original;
3
-
4
- const perms = currentPermutations
5
- ? currentPermutations
6
- : original.map((el) => [el]);
+const permutations = function (original, currentPermutations = original.map((num) => [num])) {
+ if (original.length === 0) return [];
+ if (original.length === 1) return [original];
7
8
const newPerms = [];
9
perms.forEach((el) => {
0 commit comments