Given two sorted (ascending) linked lists L1 and L2. Write a program to merge them into a single descending linked list.
Example:
-
List1 = 5 > 15 > 25 > 35 > null.
-
List2 = 1 > 10 > 20 > 30 > null.
-
ResultList = 35 > 3 0> 25 > 20 > 15 > 10 > 5 > 1 > null.
Notes and assumptions:
-
This is a singly linked list and direction is shown using the symbol >.
-
The next node of last element in null.
-
Should solve it in the most efficient manner making use of all inputs.