这来源于
class Solution {
public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
ListNode temp1 = l1;
ListNode temp2 = l2;
ListNode res = new ListNode(0);
ListNode res1 = res;
while (temp1 != null && temp2 != null){
if(temp1.val > temp2.val){
res.next= temp2;
res = res.next;
temp2= temp2.next;
}else{
res.next= temp1;
res = res.next;
temp1= temp1.next;
}
}
if (temp1 !=null && temp2 ==null){
res.next = temp1;
}
if (temp2 !=null && temp1 ==null){
res.next = temp2;
}
return res1.next;
}
}