Rotate linked list

4.3

3 votes
Problem

Given a head of a linked list, rotate the list to the right by k places.
Example: 12345
    For k=1:
    23451
    For k=2:
    34512
Input: 
first line contains t test cases
First line of each test cases contains n(number of elements in linked list) and k(number of rotations)
Second line contains n elements of the linked list.
Output:
 contains n elements of the linked list after rotation.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?