Sort the Flag — Solution & Editorial
Three-way partition with low/mid/high pointers, or simply count the three values and re-emit — both are O(N).
Complexity: O(N)
Three-way partition with low/mid/high pointers, or simply count the three values and re-emit — both are O(N).
Complexity: O(N)