Problem
You get an array candidates of integers and an integer target. The array can contain the same value more than one time. Find all the combinations of items from candidates with the sum target.
You can use each item of candidates at most one time. Two items with the same value are two different items. But two combinations are the same when they have the same values the same number of times. The result must not contain the same combination two times.
If no combination exists, return an empty list. You can return the combinations in any order, and the values in each combination in any order.
Example 1
- Input:
- candidates = [3,1,3,5,1,1], target = 8
- Output:
- [[3,5],[1,1,1,5],[1,1,3,3]]
Example 2
- Input:
- candidates = [4,4,2], target = 6
- Output:
- [[2,4]]
- Explanation:
- Each
4item with the2item gives[2, 4]. The result shows this combination only one time.
Example 3
- Input:
- candidates = [7], target = 3
- Output:
- []
Constraints
- 1 <= candidates.length <= 100
- 1 <= candidates[i] <= 50
- 1 <= target <= 30
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
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 · 5 records
Expedia
Leetcode 40. Combination Sum II
Reported Jun 4, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceLinkedIn
Leetcode 40. Combination Sum II
Reported Sep 19, 2025 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 40. Combination Sum II
Reported Jan 9, 2025 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceMicrosoft
Leetcode 40. Combination Sum II
Reported Oct 8, 2025 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source