# Longest Subarray Zero Sum

Posted: 1 Dec, 2020

Difficulty: Easy

#### Ninja loves playing with numbers. So his friend gives him an array on his birthday. The array consists of positive and negative integers. Now Ninja is interested in finding the length of the longest subarray whose sum is zero.

##### Input Format:

```
The first line contains a single integer T, denoting the number of test cases.
The first line of each test case will contain the integer N, denoting the number of elements in the given array.
The second and last line contains N space-separated integers that denote the value of the elements of the array.
```

##### Output Format

```
The first and only line of each test case in the output contains an integer denoting the length of the longest subarray whose sum is zero.
```

##### Note:

```
You are not required to print the expected output; it has already been taken care of. Just implement the function.
```

##### Constraints:

```
1 <= T <= 10
1 <= N <= 10^4
-10^5 <= arr[i] <= 10^5
Time Limit: 1 sec
```

SIMILAR PROBLEMS

Best time to buy and sell stock II

Posted: 5 Sep, 2022

Difficulty: Moderate

LRU Cache

Posted: 10 Sep, 2022

Difficulty: Moderate

Ninja And The Class Room

Posted: 19 Sep, 2022

Difficulty: Easy

Array Rotation

Posted: 21 Oct, 2022

Difficulty: Easy

Find The Single Element

Posted: 30 Oct, 2022

Difficulty: Easy