#K74327. Longest Zero-Sum Subarray
Longest Zero-Sum Subarray
Longest Zero-Sum Subarray
Given an array a of n integers, your task is to find the length of the longest contiguous subarray whose sum is zero. In other words, you need to determine the maximum length L such that there exists indices l and r (with 0 ≤ l ≤ r < n) satisfying the condition:
$$\sum_{i=l}^{r}a_i = 0$$
If no such subarray exists, output 0.
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains a single integer n, which denotes the number of elements in the array.
- The second line contains n space-separated integers representing the elements of the array.
outputFormat
Output to standard output a single integer representing the length of the longest contiguous subarray whose sum is zero.
## sample5
1 -1 3 -2 2
3