BETA

Difficulty Level:

Easy

Total Submissions: 3769 Accuracy:

46.14%

Merge 2 sorted linked list in reverse order (Function Problem)
       

Given two linked lists sorted in increasing order. Merge them such a way that the result list is in decreasing order. Both the Linked list can be of different sizes.

Input:
You have to complete the method which takes 2 argument: the head of the first linked list  and the head of second linked list. You should not read any input from stdin/console. There are multiple test cases. For each test case, this method will be called individually.

Output:
Your function should return a pointer to the list obtained by merging the two sorted linked list passed as argument.

Constraints:
1 <=T<= 50
1 <= size of linked lists <= 1000

Example:
Input:

2
4 3
5 10 15 40 
2 3 20
2 2
1 1
2 4 

 

Output:
40 20 15 10 5 3 2

4 2 1 1 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal


					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.