Count of largest size group
int count = 0 ; for ( Map . Entry < Integer , Integer > it : d . entrySet ( ) ) { int k = it . getKey ( ) ; int val = it . getValue ( ) ; if ( val > size ) { size = val ; count = 1 ; } else if ( val == size ) count += 1 ; } return count ; }