Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. Node* interleave(Node* list1, Node* list2){
  2.   // ******** WRITE YOUR CODE HERE ********
  3.   Node *returnList = new Node();
  4.   Node *temp = new Node();
  5.  
  6.   if(list2 == NULL){
  7.     copy(list1, returnList);
  8.     return returnList;
  9.   }
  10.  
  11.   if(list1 == NULL){
  12.     copy(list2, returnList);
  13.     return returnList;
  14.   }
  15.  
  16.   copy(list1, returnList);
  17.   returnList->next=temp;
  18.   while(list1->next != NULL && list2->next != NULL){
  19.     copy(list2,temp);
  20.     copy(list1->next, temp->next);
  21.     list1=list1->next;
  22.     list2=list2->next;
  23.   }
  24.   return returnList;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement