Combination Sum II
Return all distinct combinations of array entries summing to target. Each index may be used at most once; duplicate input values must not cause duplicate combinations.
Example 1
candidates = [1,1,2,3]
target = 4[[1,3],[1,1,2]]Explanation
Use 1+3 or the two separate 1 occurrences plus 2; no index is reused.
Example 2
candidates = [2,2,2]
target = 4[[2,2]]Explanation
Choosing any two of three equal 2s yields the same combination, returned once.
Example 3
candidates = [5]
target = 3[]Explanation
The sole value 5 exceeds target 3.
Constraints
- 1 <= len(candidates) <= 100
- Values are positive integers
- 1 <= target <= 30
Function contract
combinationSum2Arguments: json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
[1,1,2,3]4