Sorting in linear time

In the solution video, if(a[i] == 2) we just decemented high pointer i.e. high-- and we have not incremented curr pointer curr++.

I understood the reason that there may be a case where 2 can be swapped with 2 so we can’t increment curr pointer.

But why this is not in the case if(a[i] == 0) because in this case we incremented curr++ as well as we have done low++.

hello @vaishnavtannu
our configuration will be somehting as
000001111110<- current index
now what we are doing is we are swapping that 1 with 0.
000000111111
clearly length of zeros is increased by one that is why low++.

also because we are sure that swap will always happen between 1 and 0 (yeah no other configuration possible )

that why we are incrementing curr as well.

note - >one more configuration is possible where every element till curr is 0. (in this case, it is obvious that both low and curr should increase)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.