Rotate Array

Practice this coding question on Coding Gurukul.

Problem statement

A circular duty roster advances k positions to the right. An entry that moves past the last position wraps to the beginning. Print the updated roster; k may exceed the roster length.

Input format

First line: n k. Second line: n integers.

Output format

Print the roster after k right rotations.

Constraints

1 <= n <= 100000; 0 <= k <= 1000000000; -10000 <= value <= 10000.

Sample input

5 2
9 8 7 6 5

Sample output

6 5 9 8 7

Sign in to run or submit a solution in C++, Java or Python.