For this Question: Given an array of N elements containing only 0 and 1. Find the length of the largest subarray with an equal number of 0's and 1's.

This problem was asked in Amazon.Each test case contains two lines. The first line of each test case is a number N denoting the size of the array and in the next line are N space-separated values of A [].

Constraints:-
1 < = N < = 100000Print the max length of the subarray.Sample input
4
0 1 0 1

Sample Output
4

Sample Input
5
0 0 1 0 0

Sample Output
2, I have written this Solution Code: def maxLen(arr, n):
 
   
    hash_map = {} 
    curr_sum = 0
    max_len = 0
    ending_index = -1
 
    for i in range (0, n):
        if(arr[i] == 0):
            arr[i] = -1
        else:
            arr[i] = 1
 
    for i in range (0, n):
     
        
        curr_sum = curr_sum + arr[i]
 
       
        if (curr_sum == 0):
            max_len = i + 1
            ending_index = i
 
        if curr_sum in hash_map:
             
          
            if max_len < i - hash_map[curr_sum]:
                max_len = i - hash_map[curr_sum]
                ending_index = i
        else:
 
            
            hash_map[curr_sum] = i 
         
    for i in range (0, n):
        if(arr[i] == -1):
            arr[i] = 0
        else:
            arr[i] = 1
             
  
 
    return max_len
 

a=input()
a=input().split()
for i in range(len(a)):
	a[i]=int(a[i])

 
 
print(maxLen(a, len(a))), In this Programming Language: Python, Now tell me if this Code is compilable or not?