For this Question: Given an array arr[] of size N containing 0s and 1s only. The task is to count the subarrays having an equal number of 0s and 1s.The first line of the input contains an integer N denoting the size of the array and the second line contains N space-separated 0s and 1s.

Constraints:-
1 <= N <= 10^6
0 <= A[i] <= 1For each test case, print the count of required sub-arrays in new line.Sample Input 
7
1 0 0 1 0 1 1

Sample Output
8

The index range for the 8 sub-arrays are:
(0, 1), (2, 3), (0, 3), (3, 4), (4, 5)
(2, 5), (0, 5), (1, 6), I have written this Solution Code: import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

// don't change the name of this class
// you can add inner classes if needed
class Main {
	public static void main (String[] args) {
                      // Your code here
		Scanner sc = new Scanner(System.in);
		int arrSize = sc.nextInt();
		long arr[] = new long[arrSize];

		for(int i = 0; i < arrSize; i++)
			arr[i] = sc.nextInt();
		
		System.out.println(countSubarrays(arr, arrSize));
	}

	static long countSubarrays(long arr[], int arrSize)
	{
		for(int i = 0; i < arrSize; i++)
		{
			if(arr[i] == 0)
			 	arr[i] = -1;
		}
		long ans = 0;
		long sum = 0;
		HashMap<Long, Integer> hash = new HashMap<>();
		for(int i = 0; i < arrSize; i++)
		{
			sum += arr[i];
			if(sum == 0)
			   ans++;
			
				
			if(hash.containsKey(sum) == true)
			{
				ans += hash.get(sum);
				int freq = hash.get(sum);
				hash.put(sum, freq+1);
				
			}
			else hash.put(sum, 1);
			
			
		}

		return ans;
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?