Given a doubly linked list, a position p and an integer x. The task is to add a new node with value x at position just after pth node in the doubly linked list.
First line of input contains number of testcases T. For each testcase, first line of input contains number of nodes in the linked list, and next line contains two integers p and x.
For each testcase, there will be a single line of output which prints the modified linked list.
The task is to complete the function addNode() which head reference, position and data to be inserted as the arguments, with no return type.
1 <= T <= 200
1 <= N <= 103
0 <= p < N
2 4 5
1 2 3 4
2 4 5 6
1 44 2 3 4
Testcase 1: p = 2, and x = 6. So, 6 is inserted after p, i.e, at position 3 (0-based indexing).
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.