#C1714. Rotate Array

    ID: 44950 Type: Default 1000ms 256MiB

Rotate Array

Rotate Array

You are given an array of integers and an integer \( k \). Your task is to rotate the array to the right by \( k \) steps. The rotation should be performed in such a way that the last \( k \) elements move to the front of the array, and the remaining elements shift to the right.

For example, if the array is [1, 2, 3, 4, 5] and \( k = 2 \), the rotated array is [4, 5, 1, 2, 3].

Please note: if \( k \) is greater than the length of the array, it should be reduced modulo the length of the array.

inputFormat

The first line contains an integer \( n \), 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 \) representing the number of positions to rotate the array.

It is guaranteed that \( n \ge 0 \) and \( k \) is a non-negative integer.

outputFormat

Output a single line containing the rotated array's elements separated by a single space. If the array is empty, output an empty line.

## sample
5
1 2 3 4 5
2
4 5 1 2 3