#C498. Rotate Array to the Right

    ID: 48577 Type: Default 1000ms 256MiB

Rotate Array to the Right

Rotate Array to the Right

You are given an array of integers and an integer \( k \). Your task is to rotate the array to the right by \( k \) steps. That is, every element should be shifted to the right by \( k \) positions, and the elements at the end of the array wrap around to the beginning.

Example:

Input: 7
       1 2 3 4 5 6 7
       3
Output: 5 6 7 1 2 3 4

Note that the rotation is performed in-place. You must use the modulo operator to handle the case where \( k \) is greater than the length of the array.

inputFormat

The input consists of three lines:

  1. The first line contains an integer \( n \) representing the number of elements in the array.
  2. The second line contains \( n \) space-separated integers representing the array.
  3. The third line contains an integer \( k \) representing the number of rotation steps to the right.

outputFormat

Output the rotated array as \( n \) space-separated integers on a single line.

## sample
7
1 2 3 4 5 6 7
3
5 6 7 1 2 3 4