#C2182. Smallest Subarray With Sum

    ID: 45470 Type: Default 1000ms 256MiB

Smallest Subarray With Sum

Smallest Subarray With Sum

Given an array of positive integers and a positive integer \(X\), find the smallest contiguous subarray such that its sum is greater than or equal to \(X\). If no such subarray exists, output 0.

You can solve this problem using the sliding window (two pointers) technique.

inputFormat

The first line contains two space-separated integers \(n\) and \(X\), where \(n\) is the number of elements in the array and \(X\) is the target sum. The second line contains \(n\) space-separated positive integers.

outputFormat

Output a single integer representing the length of the smallest contiguous subarray whose sum is greater than or equal to \(X\). If no such subarray exists, output 0.

## sample
6 7
2 3 1 2 4 3
2

</p>