Combination Sum II

Given integer candidates and target, return all unique combinations summing exactly to target. Each occurrence in candidates may be used at most once.…

Given integer candidates and target, return all unique combinations summing exactly to target. Each occurrence in candidates may be used at most once. Equal-valued occurrences are separate usable copies, but equal resulting combinations must appear only once. Sort each combination increasingly and return the combinations in lexicographic order.

- 1 <= candidates.length <= 100. - 1 <= candidates[i] <= 50. - 1 <= target <= 30. - Duplicate input values are allowed; each occurrence is usable at most once.

Example 1: input candidates = [2,1,2,7,6,1,5], target = 8; output [[1,1,6],[1,2,5],[1,7],[2,6]]. Two copies of 1 may be used together; alternate equal input positions do not create extra result rows.

Example 2: input candidates = [2,5,2,1,2], target = 5; output [[1,2,2],[5]]. Two copies of 2 make a valid row with 1. The three ways to choose those equal copies produce only one row.

Example 3: input candidates = [3], target = 6; output []. The sole occurrence cannot be reused.

Category: Recursion. Topic: recursion. Difficulty: Medium. Patterns: backtracking.