Given a doubly linked list, rotate the linked list counter-clockwise by P nodes. Here P is a given positive integer and is smaller than the count of nodes(N) in a linked list.
The first line of input contains an integer T denoting the no of test cases. For each test case, the first line of input contains two integers N and P denoting the number of nodes in Linked List and the number of nodes to be rotated respectively.
For each test case, output the final linked list after the P rotations in it.
1 <= T <= 100
2 <= N <= 100
1 <= P <= N
1 2 3 4 5 6
3 4 5 6 1 2
Testcase 1: Doubly linked list after rotating 2 nodes is: 3 4 5 6 1 2.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.