#C4524. Rotate Array by One Position

    ID: 48072 Type: Default 1000ms 256MiB

Rotate Array by One Position

Rotate Array by One Position

Given an array of integers, cyclically rotate the array by one position to the right. In other words, the last element will become the first element, and every other element shifts one position to the right. If the array is empty, simply output an empty array.

For example, if the input array is \( [1, 2, 3, 4, 5] \), then after rotation it becomes \( [5, 1, 2, 3, 4] \).

The task is to implement a function/program that performs this rotation given the array as input.

inputFormat

The first line contains a single integer ( N ), representing the number of elements in the array. The second line contains ( N ) space-separated integers representing the elements of the array.

outputFormat

Output the rotated array in a single line with each element separated by a space. If the array is empty, output nothing.## sample

0