40. Combination Sum II

Practice Combination Sum II for free on NudgeCode: Medium, Backtracking pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return every unique combination of numbers from candidates that adds up to target. Each element can be used at most once, but candidates may contain equal values. No two combinations in the answer may contain the same values. The combinations, and the values inside each, can be in any order.

Example

candidates = [10,1,2,7,6,1,5], target = 8  ->  [[1,1,6],[1,2,5],[1,7],[2,6]]

Constraints