Medium · Backtracking
Permutations
Given an array nums of distinct integers, return all of its permutations (every ordering of its elements, n! arrays), in any order.
Examples
Example 1
nums=[1,2,3]Output: 6 perms
Example 2
nums=[1,2]Output: 2 perms
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.