struct ListNode
* mergeTwoLists(struct ListNode
* l1
, struct ListNode
* l2
){
struct ListNode
* l3
, *t
;
l3
=(struct ListNode
*)malloc(sizeof(struct ListNode
));
l3
->next
= NULL;
t
=l3
;
while(l1
!=NULL&&l2
!=NULL)
{
if(l1
->val
<l2
->val
)
{
t
->next
= l1
;
l1
= l1
->next
;
}
else
{
t
->next
= l2
;
l2
= l2
->next
;
}
t
= t
->next
;
}
if(l1
)t
->next
= l1
;
if(l2
)t
->next
= l2
;
return l3
->next
;
}
😃(第一次发布)有任何疑问或建议请让我知道。
转载请注明原文地址:https://ipadbbs.8miu.com/read-65029.html