Coding Challenge

Combination Sum

Medium
backtracking

Return all combinations of candidates that sum to a target.

Given distinct candidate numbers and a target, return every unique combination where chosen numbers sum to the target. A number can be used unlimited times.

Examples

Input: candidates = [2,3,6,7], target = 7

Output: [[2,2,3],[7]]

Constraints

  • Candidates are distinct

Preparing your coding workspace...