Given two linked lists of integers, shuffle merge those two lists to form a new linked list.
Example:
List1 : 1->3->5->7->9->10
List2: 2->4->6->8
Output: 1->2->3->4->5->6->7->8->9->10
Please note that after you pick elements alternatively from 2 lists, if one of the lists run out of elements, you need to pick the remaining elements from the other list and append.
public class Answer implements ShuffleMergeListsInterface {
@Override
public Node ShuffleMergeLists(Node node1, Node node2) {
//WRITE YOUR CODE HERE
}
}
// Here is the Node.java
public class Node {
public int nodeValue;
public Node nextNode;
}
Answer
Answer
No comments:
Post a Comment