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=8

Output: 4 combos

Example 2

cand=[2,5,2,1,2], t=5

Output: 2 combos

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Backtracking problems