solulubeta
Sign in
Recursion & Memo / Choices and backtracking
02.05 · Problem

Combination Sum

Medium Loop of choices, reuse allowed LC 39 Pro

Return every unique combination of candidates that adds up to target. Each number can be used many times. Order doesn’t matter: [2, 2, 3] and [3, 2, 2] are the same. Any order of answers is fine.

Examples

Example 1

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

Example 2

Input:  candidates = [2, 3, 5], target = 8
Output: [[2, 2, 2, 2], [2, 3, 3], [3, 5]]
solulu Pro

Continue this problem with Pro

Inside: step-by-step hints · 10 hidden tests · reference solutions · code editor.

Lifetime ₹1,999 ₹999 · Launch offer
Mark this problem as solved when you are finished.

Item 16 of 44 · updated 2026-10-13