Given an array A of n positive integers and a positive integer B,
find the minimal length of a contiguous subarray of which the sum ≥ B.
If there isn’t one, return 0 instead.
Your code may be run on multiple testcases ( <= 50 ). Try to come up with an optimised solution.
1 <= n (size of array A) <= 10^5 1 <= A[i] <= 10^4 1 <= B <= 2*10^9
A : Array containing some integer elements B : The number by which the sum of contiguous sub-array should be greater
A : [ 2, 3, 1, 2, 4, 3 ] B : 7
The smallest possible sub array with sum >= 7 is [4,3]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.