Rotate Right by K
Rotate the list right by K positions (the last K elements move to the front).
Input: the first line has N and K; the second line has N integers.
Output: the rotated list.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ K ≤ 1018
Sample Tests
Input 1
5 2 1 2 3 4 5
Output 1
4 5 1 2 3
Input 2
3 3 1 2 3
Output 2
1 2 3
Discussion (opens after you solve — no spoilers before)
No comments yet.