Given a doubly-linked list, a position p, and an integer x. The task is to add a new node with value x at the position just after pth node in the doubly linked list.
The first line of input contains the number of test cases T. For each test case, the first line of input contains the 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 <= 104
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).
Testcase 2: p = 0, and x = 44 . So, 44 is inserted after p, i.e, at position 1 (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.