Skip to main content

Combination Sum

MediumPremium

You are given a list of integers numbers (which may include duplicates) and an integer target. Your task is to return all unique combinations of elements from numbers that add up to the given target.

Each number in numbers may only be used once in each combination.

The output must not contain duplicate combinations, each combination should be unique.

Examples

Input: numbers: [1, 2, 5], target: 5 Output: [[5]] Input: numbers: [2, 2, 2, 2, 2], target: 4 Output: [[2, 2]]