Combination Sum III
Subsequences Pattern DSA practice problem on Onlearn.
Difficulty: hard.
Topics: What is the Combination Sum III problem and how can it be solved?, Recursion, Backtracking, Combinatorics, Arrays, combinatorics, search space optimization, recursion, backtracking, Subset & Permutation Problems.
Combination Sum III Problem Statement Find all unique combinations of k numbers such that the sum of these k numbers equals n. Only numbers from 1 to 9 are allowed. Each number can be used at most once. Input Two integers, k and n. Output Return a list of lists of integers, where each inner list represents a valid combination. The order of combinations and the numbers within a combination do not matter. Constraints 1 <= k <= 9 1 <= n <= 45 Sample Test Cases Example 1: Input: Output: Explanation: 1 + 2 + 4 = 7. Other combinations like 1 + 3 + 3 are not allowed as numbers must be distinct. Example 2: Input: Output: Explanation: 1 + 2 + 6 = 9, 1 + 3 + 5 = 9, 2 + 3 + 4 = 9.