Given two linked lists L1 and L2, the task is to print a new list obtained by merging odd position nodes of L1 with the even positioned nodes of L2 alternately.
Examples:
Input: L1 = 8->5->3->2->10->NULL, L2 = 11->13->1->6->9->NULL
Output: 8->13->3->6->10->NULL
Explanation:
The odd positioned nodes of L1 are {8, 3, 10} and the even positioned nodes L2 are {13, 6}.
Merging them alternately generates the linked list 8->13->3->6->10->NULL
Input: L1 = 1->5->10->12->13->19->6->NULL, L2 = 2->7->9->NULL
Output: 1->7->10->13->6->NULL
Explanation:
The odd positioned nodes of L1 are {1, 10, 13, 6} and the even positioned node of L2 is {7}.
Merging them alternately generates the linked list 1->7->10->13->6->NULL
Approach: Follow the steps below to solve the problem:
#Data Structures #Linked List