
Let the array ARR be [1, 2, 3] and B = 5. Then all possible valid combinations are-
(1, 1, 1, 1, 1)
(1, 1, 1, 2)
(1, 1, 3)
(1, 2, 2)
(2, 3)
The first line of input contains an integer ‘T’ denoting the number of test cases to run. Then the test case follows.
Then the first line of each test case contains two space separated integers ‘N’ and ‘B’ denoting the number of elements in the array/list and the target sum respectively.
The second line of each test case contains N space separated integers the elements of array/list ARR.
For each test case, print all possible valid combinations in separate lines. You can print combinations in any order. Elements in each combination must be in non-decreasing order.
Output for each test case will be printed in a new line.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 15
1 <= B <= 20
1 <= ARR[i] <= 20
Time Limit: 1sec
abcd