#C1289. Minimum Size Subarray Sum
Minimum Size Subarray Sum
Minimum Size Subarray Sum
You are given an array of integers and a target integer. Your task is to determine the minimum length of a contiguous subarray of which the sum is greater than or equal to the target. If no such subarray exists, output 0.
In other words, for an array \(arr\) and an integer \(target\), find the smallest \(k\) such that there exists an index \(i\) with \(\sum_{j=i}^{i+k-1} arr[j] \geq target\). This can be efficiently solved via the sliding window technique.
inputFormat
The first line of input contains two space-separated integers (n) and (target), where (n) is the number of elements in the array. The second line contains (n) space-separated integers representing the elements of the array.
outputFormat
Output a single integer representing the length of the smallest contiguous subarray whose sum is greater than or equal to (target). If no such subarray exists, output 0.## sample
6 7
2 3 1 2 4 3
2