Solution: Find K-Sum Subsets

Let’s solve the Find K-Sum Subsets problem using the Subsets pattern.

Statement

Given an array of nn distinct positive integers, find all possible subsets of these integers such that the sum of the elements in each subset equals a given target value k.

Return a 2D array, where each inner array represents a subset whose sum equals k.

Constraints:

  • 1n101 \leq n \leq 10

  • 1x1001 \leq x \leq 100 ...