#K47952. Minimum Subarray Length
Minimum Subarray Length
Minimum Subarray Length
You are given an array of n integers and an integer k. Your task is to determine the length of the shortest contiguous subarray whose sum is greater than or equal to k. If no such subarray exists, return 0.
More formally, for an array \(A\) of length \(n\), find the smallest positive integer \(L\) such that there exists an index \(i\) with
\(\sum_{j=i}^{i+L-1} A_j \geq k\)
If no valid \(L\) exists, output 0.
inputFormat
The first line of input contains two integers n and k, where n denotes the number of elements in the array, and k is the target sum. The second line contains n space-separated integers representing the elements of the array.
outputFormat
Output a single integer representing the length of the shortest contiguous subarray whose sum is at least k. If no such subarray exists, output 0.
## sample6 7
2 3 1 2 4 3
2