Backtracking Algorithms for Combination Sum and Palindrome Partitioning
Combination Sum (Problem 39)
Given a distinct integer array candidates and a target value target, find all unique combinations in candidates where the numbers sum to target. Each number may be used repeatedly.
The solution uses backtracking with these key components:
Parameters: The recursive function tracks the current sum, path, and starting ...
Posted on Tue, 26 May 2026 18:10:30 +0000 by mfindlay
Backtracking for Combination Sum, Combination Sum II, and Palindrome Partitioning
39. Combination Sum
Problem: https://leetcode.cn/problems/combination-sum/description/
Find all unique combinations of candidates where the chosen numbers sum to target. The same number may be used a unlimited number of times.
class Solution {
public:
vector<vector<int>> combinationSum(vector<int>& candidates, int targ ...
Posted on Sun, 10 May 2026 15:26:59 +0000 by Jedi Legend
Combination Sum II - Handling Duplicate Elements in Backtracking
Given an array of integers candidates and a target value target, find all unique combinations in candidates where the numbers sum to target.
Key constraints:
Each number can only be used once in each combination.
All numbers (including the target) are positive integers.
The result set must not contain duplicate combinations.
Examples
Example ...
Posted on Sun, 10 May 2026 11:27:21 +0000 by smilley654