Calculate largest number in A and mapping A to Mp
for ( int i = 0 ; i < N ; i ++ ) { M = Math . max ( M , arr [ i ] ) ; if ( Mp . containsKey ( arr [ i ] ) ) Mp . put ( arr [ i ] , 1 ) ; else Mp . put ( arr [ i ] , 0 ) ; }