K36
Subsets (Power Set)
Problem Statement & Objective
Given an integer array nums of unique elements, return all possible subsets (the power set).
Function Signature (Python)
subsets(nums: list[int]) -> list[list[int]]Input & Output Contract
Output Rule:Tüm alt kümelerin listesi.
System Constraints
1 <= sayilar.length <= 10
-10 <= sayilar[i] <= 10
Tüm sayılar benzersizdirExample Execution Walkthrough
sayilar = [1, 2, 3] -> [[], [1], [1, 2], [1, 2, 3], [1, 3], [2], [2, 3], [3]]Example Test Scenarios (3)
Example 1
Input:
[[1,2,3]]Expected Output:
[[],[1],[1,2],[1,2,3],[1,3],[2],[2,3],[3]]Example 2: Single Element
Input:
[[0]]Expected Output:
[[],[0]]Example 3
Input:
[[1,2]]Expected Output:
[[],[1],[1,2],[2]]