Assuming, the linked list is 10 -> 20 -> 30 -> 40 -> 50 -> 60 -> NULL. X = 2 and Y = 5. On reversing the given linked list from position 2 to 5, we get 10 -> 50 -> 40 -> 30 -> 20 -> 60 -> NULL.
The first line of input contains an integer ‘T’ representing the number of test cases.
The first line of every test case contains the elements of the linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.
The second line of every test case contains two space-separated integers, 'X' and 'Y', denoting the positions in the linked list.
For each test case, the resulting linked list is printed.
Print the output of each test case in a separate line.
You don’t need to print anything. It has already been taken care of. Just implement the given function.
Can you solve it in place and in one pass?
1 <= T <= 100
1 <= N <= 10^6
1 <= X, Y <= N
1 <= data <= 10^7
Time Limit: 1 sec
Note:
Algorithm:
Deletion In Doubly Linked List
Deletion In Doubly Linked List
Deletion In Doubly Linked List
Insertion In Doubly Linked List
Insertion In Doubly Linked List
Insertion In Doubly Linked List
Insertion In Doubly Linked List
LRU Cache
Delete Nodes On Regular Intervals
Add One To Linked List