#K15661. Rotate List
Rotate List
Rotate List
Given a list of integers and a number (K), the task is to rotate the list to the right by (K) steps. In other words, for a list (l), the rotated list can be expressed as (l' = l[-K:] + l[:-K]).
This problem requires you to handle multiple test cases. For each test case, you are given two integers (N) (the number of elements in the list) and (K) (the number of rotations), followed by a list of (N) integers. Your output should be the rotated list with the elements separated by a space.
inputFormat
The input starts with an integer (T) denoting the number of test cases. Each test case consists of two lines:
1. The first line contains two space-separated integers (N) and (K), where (N) is the size of the list and (K) is the number of rotations.
2. The second line contains (N) space-separated integers representing the list.
outputFormat
For each test case, print the rotated list on a single line with its elements separated by a space.## sample
1
5 2
1 2 3 4 5
4 5 1 2 3
</p>