#K51032. Rotate Array
Rotate Array
Rotate Array
Given an array of n integers and an integer k, rotate the array to the right by k steps.
This means that every element is shifted k positions to the right, and the elements that fall off the end are wrapped around to the beginning of the array.
Note: The rotation should be performed in a way such that the algorithm works efficiently even if k is larger than n.
Formally, if we denote the array as \(a_0, a_1, \ldots, a_{n-1}\), then after rotation the array becomes \(a_{n-k\%n}, a_{n-k\%n+1}, \ldots, a_{n-1}, a_0, a_1, \ldots, a_{n-k\%n-1}\).
inputFormat
The first line contains two integers n (the number of elements in the array) and k (the number of steps to rotate).
The second line contains n space-separated integers representing the array.
\(1 \leq n \leq 10^5\). The values of the array elements fit into a standard 32-bit integer. \(0 \leq k \leq 10^9\).
outputFormat
Output the rotated array as a sequence of space-separated integers on a single line.
## sample7 3
1 2 3 4 5 6 7
5 6 7 1 2 3 4