How to reach for these exact and precise logics while framing the algorithm.
How should one start while seeing a question like this?
Sort array of 0's 1's and 2's
Hi Manan,
The problem you are talking about is a classic problem of arranging items in a given way. In this, you can think about the Dutch national flag which consists of red white and blue parts. Now, if you are given N objects of red,white,blue colours and you need sort them in the order red white blue, you can use this approach. Another approach is counting but the given approach is faster on average case.