Zero Sum Subarrays
Submissions: 5851   Accuracy:

41.31%

  Difficulty: Easy   Marks: 2
       

Given an array of size N , print the total count of sub-arrays having their sum equal to 0

Input: First line of the input contains an integer T denoting the number of test cases. Each test case consists of two lines. First line of each test case contains an Integer N denoting the size of the array and the second line contains N space separated integers.

Output: Corresponding to each test case, print the total number of subarrays whose sum is equal to 0.

Constraints:    
1<= N <= 10000
-100 <= A[i] <= 100 where i <= N

Example:
Input:
2
6
0 0 5 5 0 0
10
6  -1 -3 4 -2 2 4 6 -12 -7

Output:
6
4

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Yash Kodesia
Author: Yash Kodesia 1


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.