03.07 · Problem
Subset Sum
Return true if some subset of the positive numbers adds up to exactly k. n can be 100, so 2ⁿ is far too slow. Use a memo.
Examples
Example 1
Input: nums = [3, 34, 4, 12, 5, 2], k = 9
Output: true
4 + 5 = 9.
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 26 of 44 · updated 2026-10-13