How to sort 0s 1s & 2s for an array in swift?

[Question]: In a given array sort all 0s 1s & 2s .For example: I/P {0, 1, 2, 0, 1, 2} o/p:: {0, 0, 1, 1, 2, 2}Solution:- We can use three pointers low, mid & high. Where low & mid is start index(i.e. 0) & high is arrayLength – 1. In a while loop we …

How to sort 0s 1s & 2s for an array in swift? Read More »