Given two linked lists of size N and M, which are sorted in non-decreasing order. The task is to merge them in such a way that the resulting list is in decreasing order.
First line of input contains number of testcases T. For each testcase, first line of input conatains length of both linked lists N and M respectively. Next two lines contains N and M elements of two linked lists.
For each testcase, print the merged linked list which is in non-increasing order.
The task is to complete the function mergeResult() which takes reference to the heads of both linked list and returns the pointer to the merged linked list.
1 <=T<= 50
1 <= N, M <= 1000
5 10 15 40
2 3 20
40 20 15 10 5 3 2
4 2 1 1
Testcase 1: After merging the two lists in decreasing order, we have new lists as 40->20->15->10->5->3->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.