Storing the number of occurrence of elements in unordered map
for ( int i = 0 ; i < n ; i ++ ) { if ( ! m . ContainsKey ( v [ i ] ) ) m . Add ( v [ i ] , 1 ) ; else m [ v [ i ] ] = m [ v [ i ] ] + 1 ; } int count = 0 ;