The first line contains an integer 'T' denoting the number of test cases. Then each test case follows. The first line of each test case contains a positive integer ‘N’ which represents the length of the array/list. The second line of each test case contains ‘N’ single space-separated integers representing the elements of the array/list.
For each test case, the only line of output will print the number of subarrays in which the number of 0s and 1s are equal. Print the output of each test case in a separate line.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= T <= 100 1 <= N <= 5 * 10^3 0 <= ARR[i] <= 1 Time limit: 1 sec
We will visit every subarray using two nested loops and maintain the count of 0s and 1s for each of them. Count of all the subarrays with equal 0s and 1s will be maintained in a ‘RESULT’ variable.