Sort an array of 0s, 1s and 2s || Dutch National Flag solution
[Question]: How to sort an array which has 0s, 1s and 2s Approach #1 Using Dutch National Flag I used three pointers low mid & high The sorting of 0,1,2 is as per below steps arr[0….low-1] contains 0. [most left part] arr[low….mid-1] contains 1arr[high+1….n-1] contains 2. [most right part],So we swap according to the left(0) […]
Sort an array of 0s, 1s and 2s || Dutch National Flag solution Read More »