Challenge 10: Dutch National Flag Problem
We'll cover the following
Problem Statement
Implement a function that sorts an array of , and . This is called the Dutch National Problem. Since the number can be represented as the blue color, as the white color, and as the red color, we want the array to form the Dutch flag.
Try solving this problem
inplace
and in linear time without using any extra space!
Input
An array of , and
Output
An array where the numbers , , and are sorted.
Sample Input
arr = {2, 0, 0, 1, 2, 1, 0}
Sample Output
0 0 0 1 1 2 2
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.