Generate all unique permutations of a list of distinct integers.
Constraints
Example
>>> permutations([]) [[]] >>> permutations([1]) [[1]] >>> p = permutations([1,2]) >>> sorted(p) [[1,2], [2,1]] >>> p = permutations([1,2,3]) >>> len(p) 6 >>> sorted(p) [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints