We are given an array of letters, arr, and a length, n, which is a multiple of 3. The goal is to modify arr in place to move the prefix of length n/3 to the end and the suffix of length n/3 to the beginning.
Example:
- Input:
arr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'] - Output:
['G', 'H', 'I', 'D', 'E', 'F', 'A', 'B', 'C']
l
A
0
B
1
C
2
D
3
E
4
F
5
r
G
6
H
7
I
8
Step 1 / 4
Step 1:
Initialize n=9, k=3, l=0, r=6.
Pointers: l=0, r=6
Focus: select @ [0, 6]