O64

Combination Sum I

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: ARRAY

Problem Statement & Objective

Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations where candidate numbers sum to target (unlimited reuse).

Function Signature (Python)

combination_sum(candidates: list[int], target: int) -> list[list[int]]

Input & Output Contract

Output Rule:Kombinasyonlar listesi.

System Constraints

1 <= adaylar.length <= 30
2 <= adaylar[i] <= 40
Tüm sayılar benzersizdir
1 <= hedef <= 40

Example Execution Walkthrough

adaylar = [2, 3, 6, 7], hedef = 7
[2, 2, 3] (7) ve [7] (7) -> cevap: [[2, 2, 3], [7]]

Example Test Scenarios (3)

Example 1
Input:[[2,3,6,7],7]
Expected Output:[[2,2,3],[7]]
Example 2
Input:[[2,3,5],8]
Expected Output:[[2,2,2,2],[2,3,3],[3,5]]
Example 3: İmkansız
Input:[[2],1]
Expected Output:[]
Loading Python Editor...
Input Parameters
[
  [
    2,
    3,
    6,
    7
  ],
  7
]
Expected Output
[
  [
    2,
    2,
    3
  ],
  [
    7
  ]
]