Check whether frequency of any two or more elements are same or not . If yes , return false
for ( Map . Entry < Integer , Integer > i : freq . entrySet ( ) ) { if ( uniqueFreq . contains ( i . getValue ( ) ) ) return false ; else uniqueFreq . add ( i . getValue ( ) ) ; }