class Solution { public: ListNode* Merge(ListNode* pHead1, ListNode* pHead2) { if(pHead1 == NULL && pHead2 == NULL) return NULL; if(pHead1 == NULL && pHead2 != NULL) return pHead2; if(pHead1 != NULL && pHead2 == NULL) return pHead1; if(pHead1->val > pHead2->val) { pHead2->next = Merge(pHead1, pHead2->next); } else { pHead1->next = Merge(pHead2, pHead1->next); } return pHead1; } };
原文:https://www.cnblogs.com/evidd/p/10619915.html