dsa · medium
Permutations
GreyOrangeBacktracking
Return all permutations of distinct nums. Order of the list does not matter.
Arguments
nums— the input array of integers
**Example**
`` Input: [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] ``
Constraints
1 <= nums.length <= 6, values distinct
Examples
Example 1
Input: [1,2,3] Expected: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]