Try to solve the Sort Colors problem.
We'll cover the following
Statement
Given an array, colors
, which contains a combination of the following three elements:
-
(representing red)
-
(representing white)
-
(representing blue)
Sort the array in place so that the elements of the same color are adjacent, with the colors in the order of red, white, and blue. To improve your problem-solving skills, do not utilize the built-in sort function.
Constraints:
-
colors.length
300 colors[i]
can only contain s, s, or s.