Given an array consisting of letters 'R', 'W', and 'B', sort it in place to put all the 'R' before all the 'W' and all the 'W' before all the 'B'.
Example:
- Input:
arr = ['R', 'W', 'B', 'W', 'R', 'B', 'W'] - Output:
['R', 'R', 'W', 'W', 'W', 'B', 'B']
low
mid
R
0
W
1
B
2
W
3
R
4
B
5
high
W
6
Step 1 / 3
Step 1:
Initialize low=0, mid=0, high=6.
Pointers: high=6, low=0, mid=0
Focus: select @ [0, 6]