Skip to main content

Practice · 4 of 5

Subset Sums Count

CHALLENGE
Difficulty: intermediate+25 XP

**Description:** Given n values and a target t, count the subsets summing exactly to t (the empty subset sums to 0). n is small on purpose. **Input:** Line 1: n t (1 <= n <= 22, |t| <= 10^9). Line 2: n integers (|a_i| <= 10^9). **Output:** One integer — the number of subsets with sum t. **Example:** 4 3 / 1 2 3 -1 -> 3 ({1,2}, {3}, {1,3,-1}).

Back to lesson: Practice: Recursion Problem Set