Search⌘ K
AI Features

Solution: Combination Sum

Solution: Combination Sum asks you to return every unique combination from an array of distinct integers that adds to a target, with each number available any number of times and order ignored.

Statement

Given an array of distinct integers, nums, and an integer, target, return a list of all unique combinations of nums where the chosen numbers sum up to the target. The combinations may be returned in any order.

An integer from nums may be chosen an unlimited number of times. Two combinations are unique if the frequency of at least one of the chosen integers is different.

Constraints:

  • 1≤1 \leq nums.length ≤30\leq 30
  • 2≤2 \leq nums[i] ≤40\leq 40
  • 1≤1 \leq target ≤40\leq 40
...