LogiQuest

70. Shortest Subarray with Sum ≥ S

MediumSliding WindowTwo Pointers

All values are positive. Print the length of the shortest contiguous subarray with sum at least s, or 0 if none exists.

Input format

Line 1: n s Line 2: n positive integers

Output format

The minimum length, or 0.

Example 1

Input

6 7
2 3 1 2 4 3

Output

2

Example 2

Input

3 4
1 4 4

Output

1

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.

Loading the MyLoginn IDE…