#C406. Minimal Contiguous Subarray Sum
Minimal Contiguous Subarray Sum
Minimal Contiguous Subarray Sum
Given an array \( nums \) of non-negative integers and an integer \( target \), your task is to find the length of the smallest contiguous subarray for which the sum of its elements is at least \( target \). In other words, find the minimum \( \ell \) such that there exist indices \( i \) and \( j \) with \( 0 \leq i \leq j < n \) and
\( \displaystyle \sum_{k=i}^{j} nums[k] \geq target \).
If there is no subarray meeting the condition, print 0.
The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The first line contains two integers \( n \) and \( target \) separated by space, where \( n \) is the number of elements in the array. The second line contains \( n \) space-separated non-negative integers representing the array \( nums \).
outputFormat
Output a single integer: the length of the smallest contiguous subarray whose sum is at least \( target \). If no such subarray exists, output 0.
## sample10 15
5 1 3 5 10 7 4 9 2 8
2
</p>