title: Count Subarrays Equal Number 1S 0S 1
signature: function count_subarrays_equal_number_1s_0s_1(arr, n)
source_py: def count_subarrays_equal_number_1s_0s_1(arr, n):
      mp = dict()
      Sum = 0
      count = 0
      for i in range(n):
          if (arr[i] == 0):
              arr[i] = (- 1)
          Sum += arr[i]
          if (Sum == 0):
              count += 1
          if (Sum in mp.keys()):
              count += mp[Sum]
          mp[Sum] = (mp.get(Sum, 0) + 1)
      return count
source_cpp: int count_subarrays_equal_number_1s_0s_1(vector<int> arr, int n) {
    map < int, int > mp;
    int sum = 0;
    int count = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( arr [ i ] == 0 ) arr [ i ] = - 1;
      sum += arr [ i ];
      if ( sum == 0 ) count ++;
      if ( mp [ sum ] ) count += mp [ sum ];
      if ( mp [ sum ] == 0 ) mp [ sum ] = 1;
      else mp [ sum ] ++;
    }
    return count;
  }