Given an array of strictly the characters R, G, and B, segregate the values so all Rs come first, Gs second, and Bs last. You can only swap elements. Do this in linear time and in-place. Input: a string of R, G, B characters. Output: the sorted string.
Example 1:
Example 2:
Constraints:
1 <= len(string) <= 10^5 String contains only R, G, B
Tags:
