/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
ListNode *pNode=NULL;
ListNode *pHead=NULL;
if(l1==NULL&&l2==NULL)
return NULL;
if(l1==NULL)
return l2;
if(l2==NULL)
return l1;
if(l1->val<=l2->val)
{
pNode=l1;
pHead=pNode;
pNode->next=mergeTwoLists(l1->next, l2);
}
else
{
pNode=l2;
pHead=pNode;
pNode->next=mergeTwoLists(l1, l2->next);
}
return pHead;
}
};
又没一次AC= =