Rotate a circular price buffer by k
Asked at Optiver
A ring buffer of the last n prices needs to be rotated right by k positions so the newest slot lines up at the front. Do it in place with constant extra space.
prices = [1, 2, 3, 4, 5], k = 2
-> [4, 5, 1, 2, 3]
Rotate the array right by k in place. Aim for time and space.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.