26. Left Rotate Array by K Positions

You are given an array of size n and an integer k. Rotate the array left by k positions, in-place (without using any extra array).

This means the elements that go beyond the first k positions should wrap around to the end.


Example-1

Input: n = 5, k = 2, arr = [1 2 3 4 5]
Output:[3  4  5  1  2]


Example-2

Input: n = 4, k = 1, arr = [10 20 30 40]
Output:[20  30  40  10]

 

Loading...

Input

5 2 1 2 3 4 5

Expected Output

3 4 5 1 2