369. Rotate List Right
MediumLinked List
Rotate the list to the right by k places and print it.
Input format
Line 1: n k Line 2: n values
Output format
The rotated list.
Example 1
Input
5 2 1 2 3 4 5
Output
4 5 1 2 3
Example 2
Input
3 4 0 1 2
Output
2 0 1
Constraints
1 ≤ n ≤ 10⁵ 0 ≤ k ≤ 2 × 10⁹
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…