#K941. Rotate Array
Rotate Array
Rotate Array
Given an array of integers, rotate the array to the right by k steps. In other words, each element of the array is moved to the right by k positions, and the elements that exceed the end of the array wrap around to the beginning. Mathematically, for an array \( A = [a_0, a_1, \dots, a_{n-1}] \) and a non-negative integer \( k \), the rotated array \( A' \) is given by:
\( A'_i = A_{(i - k) \mod n} \) for \( 0 \le i < n \).
For example, when arr = [1, 2, 3, 4, 5, 6, 7] and k = 3, the rotated array is [5, 6, 7, 1, 2, 3, 4].
inputFormat
The input consists of three lines:
- The first line contains an integer n, indicating the number of elements in the array.
- The second line contains n space-separated integers representing the array elements.
- The third line contains an integer k, specifying the number of rotation steps.
outputFormat
Output the rotated array as space-separated integers on one line.
## sample7
1 2 3 4 5 6 7
3
5 6 7 1 2 3 4
</p>