Find maximum frequency among all frequencies .
int max_freq = Integer . MIN_VALUE ; for ( Map . Entry < Integer , Integer > entry : freq . entrySet ( ) ) max_freq = Math . max ( max_freq , entry . getValue ( ) ) ;