Dodomeki
Sign in

93. Permutations of the List

Medium

Given a list nums with distinct values, return all ways to arrange its elements. The order of the permutations in the result does not matter.

Example 1
Input: nums = [1, 3, 6]
Output: [[1, 3, 6], [1, 6, 3], [3, 1, 6], [3, 6, 1], [6, 1, 3], [6, 3, 1]]
Example 2
Input: nums = [9]
Output: [[9]]
Constraints
  • 1 <= nums.length <= 8
  • -10 <= nums[i] <= 10
  • Todos os valores de nums são distintos.
BacktrackingArrays
Caso 1
nums =
[1,3,6]
Expected =
[[1,3,6],[1,6,3],[3,1,6],[3,6,1],[6,1,3],[6,3,1]]
Caso 2
nums =
[9]
Expected =
[[9]]

Run checks these 2 cases. Submit runs all 6, including hidden ones.