#K11536. Minimum Subarray Length
Minimum Subarray Length
Minimum Subarray Length
Given an array of positive integers and a target sum (T), your task is to find the smallest length (L) of a contiguous subarray such that the sum of its elements is at least (T). If no such subarray exists, output 0.
For example, consider the array [2, 3, 1, 2, 4, 3, 7, 2] with (T = 7). The minimum subarray that meets the condition is [7] with length 1.
inputFormat
The input is given via standard input (stdin). The first line contains two integers (N) and (T), where (N) is the number of elements in the array and (T) is the target sum. The second line contains (N) positive integers separated by spaces representing the array elements.
outputFormat
Output a single integer to standard output (stdout): the minimum length (L) of a contiguous subarray with a sum of at least (T). If no such subarray exists, output 0.## sample
8 7
2 3 1 2 4 3 7 2
1