find the min frequency
int min_count = n + 1 , res = - 1 ; foreach ( KeyValuePair < int , int > pair in count ) { if ( min_count >= pair . Value ) { res = pair . Key ; min_count = pair . Value ; } } return res ; }