Dnf question alternative approach?

this question is the same as it was in the sorting challenges section " linear time ".

the approach used there was also done in a single pass and was in place. Then what is the use of DNF algo?

YES this is same.
The algo is just called DNF sort or the Dutch National Flag Algorithm. It is a linear time sorting algo without using any extra space. (used when elements are 0,1 and 2 only or you can say when the number of distinct elements is 3)

the logic is also same right ?

Yes logic is same…Still you can watch the video and confirm

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.