Skip to content

Latest commit

 

History

History
11 lines (8 loc) · 421 Bytes

File metadata and controls

11 lines (8 loc) · 421 Bytes

Exercise 20 - permutations

Write a function that takes in an empty array or an input array of an consecutive positive integers, starting at 1, and returns an array of all possible permutations of the original array

The integers will not repeat.

permutations([1, 2, 3]); // [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
// An empty set has a single permutation, 0! = 1
permutations([]); // [[]]