Medium · Backtracking
Combination Sum II
Given an array candidates of positive integers (values may repeat) and a positive integer target, return every distinct combination of candidates that sums to target, using each array element at most once and listing each combination once, in any order.
Examples
Example 1
cand=[10,1,2,7,6,1,5], t=8Output: 4 combos
Example 2
cand=[2,5,2,1,2], t=5Output: 2 combos
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.