K38

Permutations of Array Elements

Junior Level Candidate
Target Time: 15 - 20 Minutes
Type: ARRAY

Problem Statement & Objective

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

Function Signature (Python)

permute(nums: list[int]) -> list[list[int]]

Input & Output Contract

Output Rule:Tüm permütasyonların listesi.

System Constraints

1 <= sayilar.length <= 6
-10 <= sayilar[i] <= 10
Tüm sayılar benzersizdir

Example Execution Walkthrough

sayilar = [1, 2, 3] -> [[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]

Example Test Scenarios (3)

Example 1
Input:[[1,2,3]]
Expected Output:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Example 2: İki Eleman
Input:[[0,1]]
Expected Output:[[0,1],[1,0]]
Example 3: Single Element
Input:[[1]]
Expected Output:[[1]]
Loading Python Editor...
Input Parameters
[
  [
    1,
    2,
    3
  ]
]
Expected Output
[
  [
    1,
    2,
    3
  ],
  [
    1,
    3,
    2
  ],
  [
    2,
    1,
    3
  ],
  [
    2,
    3,
    1
  ],
  [
    3,
    1,
    2
  ],
  [
    3,
    2,
    1
  ]
]