We initially put 2 pointers: "one" and "two" at the head of the linked lists.
We make a new list for storing the resultant linked list "res".
Now, we compare the values at both the pointers. The smaller value is added at the last of "res" and its pointer is increased by one step.
In our example, values at "one" and "two" are compared. Since 7<10, therefore 7 is added to the last of "res" and "two" is moved by one step as shown in figure 4.
Again we compare the values at the pointers. Since 9<10, so 9 is added to the last of "res" and the "two" pointer is increased again.
Again on comparing, 10<12, so "one" is increased and 10 is added to the last of "res".
This process keeps repeating until one of the linked lists i.e. the list of smaller size reaches null. At that time the positions will look like as shown in figure 7.
Then, the remaining elements of the other larger linked list are added to "res" as they are already sorted and greater than the elements of the previous linked list.
Here, since "one" pointer reaches null and 60 is left in the other list, therefore 60 is added to "res".
Can you code this algorithm on your own? Take hints from the code given below if you get stuck.