Timer is Running

Smallest subarray with sum greater than x
##### Submissions: 17780   Accuracy: 47.73%   Difficulty: Easy   Marks: 2

Given an array of integers (A[])  and a number x, find the smallest subarray with sum greater than the given value.

```Examples:
A[] = {1, 4, 45, 6, 0, 19}
x  =  51
Output: 3
Minimum length subarray is {4, 45, 6}

A[] = {1, 10, 5, 2, 7}
x  = 9
Output: 1
Minimum length subarray is {10}
```

Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains two space separated integers N and x. Then in the next line are N space separated values of the array.

Output:
For each test case in a new line print the required ouput.

Constraints:
1<=T<=100
1<=N,x<=1000
1<=A[]<=1000

Example:
Input:

2
6 51
1 4 45 6 0 19
5 9
1 10 5 2 7
Output:
3
1

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Shivam Gupta
Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.