Iterating over the map
for ( Map . Entry < Character , Integer > it : freq . entrySet ( ) ) { if ( it . getValue ( ) % 2 == 1 ) count ++ ; } if ( count > k ) System . out . print ( " No " + "NEW_LINE"); else System . out . print ( " Yes " + "NEW_LINE"); }