Given a linked list of size N and a key. The task is to insert the key in the middle of the linked list.
First line of input contains number of testcases T. For each testcase, first line contains length of linked list N and next line contains N elements to be inserted into the linked list and the last line contains the element to be inserted to the middle.
For each testcase, there will be a single line of output containing the element of modified linked list.
The task is to complete the function insertInMiddle() which takes head reference and element to be inserted as the arguments. The printing is done automatically by the driver code.
1 <= T <= 100
1 <= N <= 103
1 2 4
10 20 40 50
1 2 3 4
10 20 30 40 50
Testcase 1: The new element is inserted after the current middle element in the linked list.
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.