Return subsets sum to K

Given an array A and an integer K, return all subsets of A which sum to K.

Subsets are of length varying from 0 to n, that contain elements of the array. But the order of elements should remain same as in the input array.
Note : The order of subsets are not important.

Input format :

Line 1 : Size of input array

Line 2 : Array elements separated by space

Line 3 : K

Sample Test:
Input:
9 
5 12 3 17 1 18 15 3 17 
6
Output:
3 3
5 1

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem