Problem of the day
Input: ‘K’ = 2, ‘N’ = ‘5’
Output: [[1, 4], [2, 3]]
1 + 4 = 5 and 2 + 3 = 5. Only these two combinations are there which sum upto n so answer is [[1, 4], [2, 3]].
The first line will contain the integer 'T', denoting the number of test cases.
The second line will contain the value of ‘K’.
The third line will contain the value of ‘N’.
For each test case, print all the possible combinations. If there is no combination -1 will be printed on the console.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
2 <= K <= 9
1 <= N <= 60
Time Limit: 1 sec
2
2
5
3
8
1 4
2 3
1 2 5
1 3 4
For the first case:
1 + 4 = 5 and 2 + 3 = 5. Only these two combinations are there which sum upto n so answer is [[1, 4], [2, 3]].
For the second case:
1 + 2 + 5 = 8 and 1 + 3 + 4 = 8. Only these two combinations are there which sum upto n so answer is [[1, 2, 5], [1, 3, 4]].
2
4
10
3
9
1 2 3 4
1 2 6
1 3 5
2 3 4