


The first line contains an integer ‘T’ denoting the number of test cases. Then each test case follows.
The first input line of each test case contains two space-separated integers ‘N’ and ‘K’.
The second input line of each test case contains ‘N’ space-separated integers denoting the elements of the given array.
For each test case, print the K-th largest sum subarray.
The output of each test case will be printed in a separate line.
Note: You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= T <= 50
1 <= N <= 100
1 <= K <= (N * (N + 1)) / 2
-1000 <= ARR[i] <= 1000
Where ‘T’ is the number of test cases, ‘N’ is the length of the given array/list, ‘K’ is the given integer and ARR[i] denotes the i-th element of the given array/list.
Time limit: 1 sec
The key idea of this approach is to find the subarray sum of every possible subarray and store it in an array/list. We can easily get the k-th largest element after sorting the array/list in non-increasing order.
Consider the following steps:
The key idea of this approach is to use a min-heap to store the sum of subarrays.
Consider the following steps: