try my best

###### Leetcode: Merge Two Sorted Lists
/**
* struct ListNode {
*     int val;
*     ListNode *next;
*     ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
ListNode *ans=new ListNode(0);
while(l1 && l2){
if(l1->val<l2->val){
ans->next=l1;
ans=ans->next;
l1=l1->next;
}
else{
ans->next=l2;
l2=l2->next;
ans=ans->next;
}
}
if(l1){
ans->next=l1;
}
if(l2){
ans->next=l2;
}

}
};

#### [LeetCode] 021. Merge Two Sorted Lists (Easy) (C++/Python)

2015-03-04 20:11:32

#### 【leetcode c++】21 Merge Two Sorted Lists

2015-06-18 13:37:28

#### [leetcode-排序]--21. Merge Two Sorted Lists

2017-02-05 16:53:38

#### LeetCode 21：Merge Two Sorted Lists

2015-05-27 23:08:48

#### Leetcode 21. Merge Two Sorted Lists(C++)

2017-04-24 15:02:29

#### LeetCode 21 Merge Two Sorted Lists（合并两个已排序的链表）（Linked List）

2015-11-10 20:38:04

#### 21. Merge Two Sorted Lists（python）

2016-09-18 21:32:17

#### Merge Two Sorted Lists -- LeetCode

2014-02-22 23:31:00

#### leetcode第21题——*Merge Two Sorted Lists

2016-02-28 10:09:15

#### [C语言][LeetCode][21]Merge Two Sorted Lists

2016-03-04 08:26:24

## 不良信息举报

Leetcode: Merge Two Sorted Lists