A fitness tracker logs the net calorie change for each of
Find the length of the longest contiguous streak of days whose net calorie change sums to exactly a target value
The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the number of days and the target sum. If KaTeX can only parse string typed expression, there are no days.
The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression.
Print a single integer — the length of the longest streak summing to exactly KaTeX can only parse string typed expression, or KaTeX can only parse string typed expression if no such streak exists.
Input
6 3
2 -1 3 1 -2 4Output5ExplanationThe streak from day 1 to day 5 (KaTeX can only parse string typed expression) sums to exactly the target, and has length 5, which is the longest such streak.
Example 2:
Input
3 100
1 2 3Output0ExplanationNo contiguous streak of days sums to KaTeX can only parse string typed expression, so the answer is KaTeX can only parse string typed expression.
Example 3:
Input
1 5
5Output1ExplanationThe single day itself sums to exactly the target, giving a streak of length 1.