Problem title
Difficulty
Avg time to solve

Strongly Connected Components (Tarjan’s Algorithm)
Hard
15 mins
Common Elements In Three Sorted Arrays
Moderate
35 mins
Minimize Cash Flow
Easy
15 mins
Rat In A Maze
Easy
15 mins
Shopping Options
Easy
--
Subarrays With Zero Sum
Easy
--
Sum Between Zeroes
Easy
20 mins
Diagonal Anagram
Moderate
20 mins
Palindrome Partitioning ll
Hard
40 mins
Second largest element in the array
Easy
15 mins
22

Subarrays With Zero Sum

Difficulty: EASY
Contributed By

Problem Statement

You are given ‘N’ integers in the form of an array ‘ARR’. Count the number of subarrays having their sum as 0.

For example :
Let ‘ARR’ be: [1, 4, -5]
The subarray [1, 4, -5] has a sum equal to 0. So the count is 1.
Input Format :
The first line of input contains an integer ‘T’, denoting the number of test cases.

The first line of each test case contains an integer, ‘N’, representing the size of the array.

The second line of each test case contains ‘N’ space-separated integers, representing the array ‘ARR’ elements.
Output Format :
For each test case, print the sorted array.

Print output of each test case in a separate line.
Note :
You do not need to print anything. It has already been taken care of. Just implement the given function. 
Constraints :
1 <= T <= 10
1 <= N <= 10^5
-10^5 <= ARR[i] <= 10^5

Time Limit: 1 sec
Sample Input 1 :
2
3
1 4 -5
4
-1 1 0 1
Sample Output 1 :
1
3
Explanation For Sample Output 1 :
For test case 1: 
The subarray [1, 4, -5] has a sum equal to 0. 
So the count is 1.

For test case 2: 
The subarray [-1, 1], [-1, 1, 0] and  [0] has a sum equal to 0. 
So the count is 3.
Sample Input 2 :
2
4
-1 0 1 -1
3
-2 0 2
Sample Output 2 :
4
2
Reset Code
Full screen
copy-code
Console