Problem
You get an array candidates of different integers and an integer target. Find all the combinations of numbers from candidates with the sum target.
You can use each number from candidates any number of times. Two combinations are different when at least one number appears a different number of times in them.
Return a list of all the different combinations. If no combination exists, return an empty list. You can return the combinations in any order, and the numbers in each combination in any order.
Example 1
- Input:
- candidates = [3,4,5], target = 8
- Output:
- [[3,5],[4,4]]
- Explanation:
3 + 5 = 8and4 + 4 = 8. The combination[4, 4]uses the number 4 two times.
Example 2
- Input:
- candidates = [2,7], target = 11
- Output:
- [[2,2,7]]
Example 3
- Input:
- candidates = [6], target = 4
- Output:
- []
- Explanation:
- No combination has the sum 4.
Constraints
- 1 <= candidates.length <= 30
- 2 <= candidates[i] <= 40
- All the numbers in candidates are different.
- 1 <= target <= 40
- Each input has fewer than 150 different combinations.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Combination Sum II
Coding
- Combination Sum III
Coding
- Combination Sum IV
Coding
- 2 Sum in leetcode question
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Expedia
Leetcode 39. Combination Sum
Reported Jun 4, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source