Write a function called zipLists which takes two linked lists as arguments. Zip the two linked lists together into one so that the nodes alternate between the two lists and return a reference to the head of the zipped list. Try to keep additional space down to O(1).
Extend the linked list with this method:
zipLists(linkedListOne, LinkedListTwo)(interleaveslinkedListOneandlinkedListTwoto a single linked list)
Input: a linked listlinkedListOneand a linked listlinkedListTwo
Output: a reference to the head of the interleaved linked list
Edge case(s):
- Either linked list is empty (Throw error)
linkedListOneis smaller thanlinkedListTwo(Passes)linkedListTwois smaller thanlinkedListOne(Passes)
Write tests to prove the following functionality:
linkedListOne is smaller than linkedListTwolinkedListTwo is smaller than linkedListOne