标签:http load tle c++实现 loading nbsp 描述 mamicode off
class Solution { public: ListNode* Merge(ListNode* pHead1, ListNode* pHead2) {
if(!pHead1)
return pHead2;
if(!pHead2)
return pHead1;
ListNode* pHead3 = new ListNode(0); ListNode * p1 = pHead1; ListNode * p2 = pHead2; ListNode * p3 = pHead3; while(p1&&p2){ if(p1->val <= p2->val){ p3->next = p1; p1 = p1->next; p3 = p3->next; } else{ p3->next = p2; p2 = p2->next; p3 = p3->next; } } if(p1) p3->next = p1; if(p2) p3->next = p2; return pHead3->next; } };
结果:
标签:http load tle c++实现 loading nbsp 描述 mamicode off
原文地址:https://www.cnblogs.com/ttzz/p/13295527.html