#K62057. List Rotation
List Rotation
List Rotation
You are given a list of integers and a rotation step value. The task is to rotate the list to the right by the given number of steps. If the rotation step is negative, perform a left rotation by the absolute value of the steps. The effective rotation is computed using the formula (steps_{effective} = steps \bmod n), where (n) is the length of the list. After the rotation, output the list as a sequence of space-separated integers.
inputFormat
The first line of input contains an integer (n) which denotes the number of elements in the list. The second line contains (n) space-separated integers representing the list elements. The third line contains an integer (steps) indicating the number of steps to rotate the list.
outputFormat
Output a single line containing the rotated list as space-separated integers. If the list is empty (i.e., (n = 0)), output an empty line.## sample
5
1 2 3 4 5
2
4 5 1 2 3