LeetCode 39 Combination Sum - Problem Statement

The problem

Given an array of distinct integers and a target, return all unique combinations that sum to the target.

You can use the same number unlimited times. Different orderings of the same combination count as one.

With candidates = [2, 3, 6, 7] and target = 7:

  • [2, 2, 3]: 2 + 2 + 3 = 7 ✓
  • [7]: 7 = 7 ✓

Result: [[2, 2, 3], [7]].

Note: [3, 2, 2] is the same combination as [2, 2, 3].

Constraints: 11 \le candidates 30\le 30. 22 \le target 40\le 40.