You are given two singly linked lists.
You task is to merge into into a single list. The merge should be done in a "zipper" fashion, alternating nodes from each list. The head of the first list should be the head of the merged list.
If one list is longer than the other, the remaining nodes of the longer list should be appended to the end of the merged list.
list1 = 1 → 2 → 3 → null
list2 = 4 → 5 → 6 → null
1 → 4 → 2 → 5 → 3 → 6 → null
The nodes are taken alternately from each list: 1 from list1, 4 from list2, 2 from list1, 5 from list2, and so on.
list1 = 1 → 2 → 3 → 4 → null
list2 = 5 → 6 → null
1 → 5 → 2 → 6 → 3 → 4 → null
After list2 is exhausted, the remaining nodes of list1 (3 and 4) are appended to the end.
list1 = 1 → 2 → null
list2 = 3 → 4 → 5 → 6 → null
1 → 3 → 2 → 4 → 5 → 6 → null
After list1 is exhausted, the remaining nodes of list2 (4, 5, and 6) are appended to the end.
list1 = 1 → 2 → 3 → null
list2 = 4 → 5 → 6 → null
1 → 4 → 2 → 5 → 3 → 6 → null