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

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.