#C10310. Maximum Length Subarray Sum
Maximum Length Subarray Sum
Maximum Length Subarray Sum
You are given an array of integers and a target integer \( T \). Your goal is to determine the maximum length \( L \) of a contiguous subarray whose sum equals \( T \). More formally, find the maximum \( L \) such that there exist indices \( i \) and \( j \) (with \( 0 \le i \le j < n \)) satisfying:
\( \sum_{k=i}^{j} a[k] = T \)
If no such subarray exists, output 0. The input size may be large, so an efficient solution is required.
inputFormat
The first line contains two integers \( n \) and \( T \): the number of elements in the array and the target sum respectively. The second line contains \( n \) space-separated integers representing the array \( a[0], a[1], \ldots, a[n-1] \).
outputFormat
Output a single integer: the maximum length of a contiguous subarray whose sum equals \( T \), or 0 if no such subarray exists.
## sample5 3
1 -1 5 -2 3
4