Combination Sum II

Medium Solved

Description

Given a collection of candidate numbers candidates (which may contain duplicates) and a target number target, return all unique combinations where the chosen numbers sum to target.

Each number in candidates may be used once.

Input format:

  • Line 1: JSON array of integers (candidates)
  • Line 2: Integer target
Input:
[10,1,2,7,6,1,5]
8

Output:
[[1,1,6],[1,2,5],[1,7],[2,6]]

Note:

Order of combinations does not matter.

No submissions yet.

Discuss sorting, duplicate skipping, and backtracking.

Test Cases