count total number of '0' , '1' and '2' count [ 0 ] will store total number of '0' s count [ 1 ] will store total number of '1' s count [ 2 ] will store total number of '2' s
while ( ptr != null ) { count [ ptr . data ] ++ ; ptr = ptr . next ; } var i = 0 ; ptr = head ;