#K84277. Array Right Shift
Array Right Shift
Array Right Shift
You are given an array of integers and a non-negative integer k. Your task is to shift the array to the right by k steps. After shifting, the element normally at index i will move to index \( (i + k) \mod n \), where \( n \) is the length of the array.
For example, if \( arr = [1,2,3,4,5] \) and \( k = 2 \), then the output should be \( [4,5,1,2,3] \).
The problem requires you to process multiple test cases. For each test case, you will be provided with the size of the array, the shift amount, and the array elements. You need to output the shifted array for every test case.
inputFormat
The first line contains an integer T, the number of test cases. For each test case, the first line contains two integers N and k, where N is the number of elements in the array, and k is the number of positions to shift the array to the right. The second line contains N space-separated integers representing the array elements.
Input is provided via standard input (stdin).
outputFormat
For each test case, output a single line with the elements of the shifted array separated by spaces. Output is written to standard output (stdout).
## sample4
5 2
1 2 3 4 5
6 7
10 20 30 40 50 60
3 3
1 2 3
4 4
4 3 2 1
4 5 1 2 3
60 10 20 30 40 50
1 2 3
4 3 2 1
</p>