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

Open every published interview problem, solution, scene, and memory room free, with no account.

More Backtracking problems