K38
Permutations of Array Elements
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 benzersizdirExample 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]]