Variables to maintain the count of 0 ' s , ▁ ▁ 1' s and 2 's in the array
int count0 = 0 , count1 = 0 , count2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 0 ) count0 ++ ; if ( arr [ i ] == 1 ) count1 ++ ; if ( arr [ i ] == 2 ) count2 ++ ; }