You get an array nums of distinct integers. Return every ordering of all its numbers: each permutation uses every number of nums exactly once, and two permutations differ when the numbers come in a different order.
An array of n numbers has n! permutations, and each must appear once. You may list the permutations in any order, but the numbers inside each one must be in the order of that permutation.
Three choices for the first number, two for the second and one for the last make 3! = 6 orderings.
Two numbers can come in either order.
A single number has one ordering: itself.
Constraints
1 <= nums.length <= 6-10 <= nums[i] <= 10nums are all different.Build each permutation one position at a time: for the next position, try every number not used yet.