Set the count array to 0 , count [ ] stores the total frequency of array elements
long long count [ MAX + 1 ] ; memset ( count , 0 , sizeof ( count ) ) ; for ( int i = 0 ; i < n ; ++ i ) ++ count [ arr [ i ] ] ;