LogiQuest

68. Longest Subarray with Sum K

MediumPrefix SumHash Map

Print the length of the longest contiguous subarray whose sum is k, or 0 if there is none.

Input format

Line 1: n k Line 2: n integers

Output format

The length.

Example 1

Input

6 15
10 5 2 7 1 9

Output

4

Example 2

Input

3 6
-1 2 3

Output

0

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…