Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Permutations

XPChallenge Points: 20
levelLevel: Medium

Given an array nums of distinct integers, return all possible permutations of the numbers.

The order of the returned list of permutations does not matter.

Example 1:

Input: nums = [2,4,6]

Output: [ [2,4,6], [2,6,4], [4,2,6], [4,6,2], [6,2,4], [6,4,2] ]

Explanation:

All unique arrangements of 2, 4, and 6.

Example 2:

Input: nums = [5,7]

Output: [ [5,7], [7,5] ]

Explanation:

Two possible orderings.

Example 3:

Input: nums = [9]

Output: [ [9] ]

Explanation:

Only one permutation for a single-element array.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result