Backtracking Algorithm Practice: Combination Sum III and Letter Combinations

Problem 216: Combination Sum III Description: Given two integers k and n, find all possible combinations of k numbers from 1 to 9 that add up to n. Each number can only be used once in a combination. Approach This problem requires finding subsets of size k from the set [1,2,3,4,5,6,7,8,9] where the sum equals n. The parameter k represents the d ...

Posted on Sat, 15 Aug 2026 16:09:44 +0000 by heerajee

Dynamic Programming: Knapsack Problems and Combination Counting

Both knapsack problems and combination counting problems follow a similar pattern in dynamic programming. Each element in a sequence has two states: selected or not selected. The current state can be derived from the previous state based on these two choices. DP Array Definition The definition of the dp array depends on the problem requirements ...

Posted on Sat, 18 Jul 2026 16:50:19 +0000 by drax

Backtracking Problems: Combination Sum and Palindrome Partitioning

39. Combination Sum The key insight for this problem is understanding how elements can be reused during the search process. When recursively exploring combinations, each element can be selected multiple times since we continue searching from the current index rather than moving to the next one. Consider the tree structure: after selecting an el ...

Posted on Thu, 07 May 2026 06:45:14 +0000 by rachelk