Combination Sum | Backtracking (opens in new tab)
leetcode.com Problem Statement Given an array of distinct integers candidates and a target value target, return all unique combinations where the chosen numbers sum to the target. A number may be chosen unlimited times. Brute Force Intuition For every element, we have two choices: Pick it Skip it If we pick an element, we can pick it again because repetitions are allowed. We keep exploring all possible combinations until: Target becomes 0 → Valid combination Target becomes negative → Invalid ...
Read the original article