Generate Permutations
Hard
recursion
Google
Amazon
Two Sigma
Generate all permutations of a list of unique integers using recursion. Return them sorted lexicographically.
Example
permutations([1, 2, 3])
# => [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
Test Cases
Python Editor
Output
Click "Run" to see results...