Permutations
Given an array nums of **distinct** integers, return all the possible permutations of its elements.
A permutation is an arrangement of every element exactly once; for n distinct numbers there are n! of them. You may return the list of permutations in any order, but each individual permutation must use every element exactly once in the order you place them.
Example cases
- three elementsin nums = [1,2,3]out [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]All 3! = 6 orderings.
- two elementsin nums = [0,1]out [[0,1],[1,0]]
- singlein nums = [1]out [[1]]
Constraints
- 1 <= nums.length <= 6
- -10 <= nums[i] <= 10
- All integers of nums are distinct.
nums =
[1,2,3]