02.04 · Problem
Count Subsets With Sum K
Count the subsets of positive numbers that add up to exactly k. Subsets are picked by position, so equal numbers at different positions count separately. The empty subset has sum 0.
Examples
Example 1
Input: nums = [1, 2, 3], k = 3
Output: 2
[3] and [1, 2].
solulu Pro
Continue this problem with Pro
Inside: step-by-step hints · 11 hidden tests · reference solutions · code editor.
Lifetime ₹1,999 ₹999 · Launch offer
Item 15 of 44 · updated 2026-10-13