Key in map will store elements and value will store the frequency of the elements
Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; ++ i ) if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } int answer = 0 ; foreach ( KeyValuePair < int , int > i in mp ) {