#K86672. Minimum Length Subarray
Minimum Length Subarray
Minimum Length Subarray
Given an array of positive integers and a target sum ( k ), find the minimum length ( L ) of a contiguous subarray such that its sum is at least ( k ). In other words, if ( A = [a_1, a_2, \dots, a_n] ) then find the smallest integer ( L ) for which there exists an index range ( i ) to ( j ) (with ( j - i + 1 = L )) satisfying ( \sum_{t=i}^{j} a_t \ge k ). If no such subarray exists, output 0.
Note: You are required to read input from standard input (stdin) and output the result to standard output (stdout).
inputFormat
The first line of input contains two space-separated integers ( n ) and ( k ), where ( n ) is the number of elements in the array and ( k ) is the target sum. The second line contains ( n ) space-separated positive integers representing the array.
outputFormat
Output a single integer representing the minimum length of a contiguous subarray whose sum is at least ( k ). If no such subarray exists, output 0.## sample
6 7
2 3 1 2 4 3
2