Skip to content

Commit 1e8c8f2

Browse files
nik-revmao-sz
andauthored
feat(permutations): update to inline logic within default parameter
Co-authored-by: MaoShizhong <[email protected]>
1 parent 9e5041a commit 1e8c8f2

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

16_permutations/solution/permutations-solution.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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]);
1+
const permutations = function (original, currentPermutations = original.map((num) => [num])) {
2+
if (original.length === 0) return [];
3+
if (original.length === 1) return [original];
74

85
const newPerms = [];
96
perms.forEach((el) => {

0 commit comments

Comments
 (0)