#C1795. Minimum Size Subarray Sum
Minimum Size Subarray Sum
Minimum Size Subarray Sum
Given an array of integers nums and an integer x, find the minimal length L of a contiguous subarray of which the sum is at least x. If no such subarray exists, return 0.
In other words, find the smallest L such that there exists an index i where \[ \sum_{j=i}^{i+L-1} nums[j] \ge x \] If no valid L exists, output 0.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains a sequence of integers separated by spaces representing the array nums. If the array is empty, the line will be empty.
- The second line contains a single integer x.
outputFormat
Output a single integer on standard output (stdout) representing the minimal length of a contiguous subarray whose sum is at least x. If no such subarray exists, output 0.
## sample2 3 1 2 4 3
7
2