Stores the frequency of the array elements
Dictionary < int , int > mp1 = new Dictionary < int , int > ( ) ; Dictionary < int , int > mp2 = new Dictionary < int , int > ( ) ; foreach ( int x in A ) { if ( mp1 . ContainsKey ( x ) ) mp1 [ x ] = mp1 [ x ] + 1 ; else mp1 . Add ( x , 1 ) ; } mp2 = new Dictionary < int , int > ( mp1 ) ;