Generate all permutations of an array
Problem Given an array of distinct integers, return all possible permutations (in any order).
Input / Output
- Input: an integer array
numsof distinct values. - Output: a list of all permutations of
nums.
Constraints
- 1 <= nums.length <= 8; there are n! permutations. Handle length-1 input; do not emit duplicates.
Example
- nums = [1,2,3] -> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
asked …