Files
dualfroz 5894b8b560 fix(permutations-heap): do the swaps on a copy of the input
Heap's Algorithm generates each permutation by swapping two elements of a
working array in place, and that working array was the argument itself, so
permutationsHeap([1, 2, 3]) left the caller holding [3, 2, 1]. Two calls on
one array returned different lists, and a frozen array threw.

Copy the input up front and swap on the copy, as shuffle and numericSort
already do. The returned permutations are unchanged.
2026-09-03 14:06:28 +02:00
..