Guest User

Untitled

a guest
May 20th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. /**
  2. * Definition for singly-linked list.
  3. * struct ListNode {
  4. * int val;
  5. * ListNode *next;
  6. * ListNode(int x) : val(x), next(NULL) {}
  7. * };
  8. */
  9. class Solution {
  10. public:
  11. ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
  12. ListNode* temp;
  13.  
  14. if(l1==nullptr||l2==nullptr)
  15. {
  16. temp=nullptr;
  17. return temp;
  18. }else
  19. {
  20. temp=new ListNode(l1->val);
  21. temp->next=new ListNode(l2->val);
  22. temp->next->next=mergeTwoLists(l1->next,l2->next);
  23. }
  24. return temp;
  25. }
  26. };
Add Comment
Please, Sign In to add comment