#K43822. Rotate List
Rotate List
Rotate List
Problem Statement:
You are given a list of n integers and an integer k. Your task is to rotate the list to the right by k steps. Formally, given a list \(A = [a_1, a_2, \dots, a_n]\), the rotated list will be:
\( [a_{n-k+1}, \dots, a_n, a_1, \dots, a_{n-k}] \)
Note that if k is greater than n, it should be reduced modulo n (i.e., \( k = k \mod n \)).
Print the rotated list as a sequence of space-separated integers.
inputFormat
Input Format:
- The first line contains a single integer n representing the number of integers in the list.
- The second line contains n space-separated integers.
- The third line contains a single integer k representing the number of steps to rotate the list.
outputFormat
Output Format:
Output a single line containing the rotated list as space-separated integers.
## sample5
1 2 3 4 5
2
4 5 1 2 3