Longest Subarray with Sum K (Positives)
Given an array of positive integers, find the length of the longest subarray whose elements sum to exactly K.
Input format
The first line contains N and K. The second line contains N positive integers.
Output format
Print the length of the longest subarray with sum exactly K (0 if none exists).
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
5 5
2 3 5 1 9Expected output
2Example 2
Input
3 100
1 2 3Expected output
0