标签:null wol lis class else ini sorted head color
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* mergeTwoLists(struct ListNode* l1, struct ListNode* l2) { struct ListNode sentinel; struct ListNode *sortedTail = &sentinel; while (l1 != NULL && l2 != NULL) { if (l1->val < l2->val) { sortedTail->next = l1; sortedTail = l1; l1 = l1->next; } else { sortedTail->next = l2; sortedTail = l2; l2 = l2->next; } } if (l1 != NULL) { sortedTail->next = l1; } else { sortedTail->next = l2; } return sentinel.next; }
大退步。。用了20分钟T_T
l1
/
sortedHead->...->sortedTail
\
l2
标签:null wol lis class else ini sorted head color
原文地址:http://www.cnblogs.com/agentgamer/p/6725642.html