Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Combination Sum

Given distinct positive integers (candidates) and a target, print all unique combinations whose elements sum to target. A number may be used any number of times. Each combination is printed in non-decreasing order and combinations are listed in lexicographic order.

Constraints

1 <= n <= 30 2 <= candidates[i] <= 40 1 <= target <= 40

Discussion

No discussions yet.

Rewards · v2.1

Join Shalyam Newsletter

Get exclusive insights with every issue: education, research and innovation news.

One email a week. Unsubscribe any time.