


The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain two integers ‘N’ and ‘X’ that denote the size of the ‘ARR’ and the given value respectively.
The second line of each test case contains ‘N’ space-separated integers ‘A[i]’, these are the numbers present in our ‘ARR’.
For each test case, print an integer denoting the length of the minimum subarray whose sum is greater than ‘X’.
Output for every test case will be printed in a separate line.
You don’t need to print anything; It has already been taken care of.
1 <= T <= 10^2
1 <= N <= 10^3
1 <= X <= 10^9
0 <= A[i] <= 10^9
Time Limit: 1 sec
The basic idea of this approach is to iterate the whole ‘ARR’ from start and find the sum of all the possible subarrays and find out the length of the minimum subarray whose sum is greater than the given value. We will use two loops and calculate the sum for all the possible subarrays and select the subarrays that match our given conditions.
Here is the algorithm:
As all the elements in the ‘ARR’ are positive, if a subarray has a sum greater than ‘TARGET’ then adding other elements to the current subarray will make the sum even greater. The idea is to start with an empty subarray and add elements to it until its sum is greater than ‘TARGET’. As soon as the sum is greater than ‘TARGET’ remove the starting element from the current sum.
Here is the algorithm: