给你两个链表 list1 和 list2 ,它们包含的元素分别为 n 个和 m 个。
请你将 list1 中下标从 a 到 b 的全部节点都删除,并将list2 接在被删除节点的位置。
struct ListNode* mergeInBetween(struct ListNode* list1, int a, int b, struct ListNode* list2)
{
struct ListNode *head;
struct ListNode *start;
struct ListNode *end;
struct ListNode *np;
struct ListNode *save;
int inode=-1;
np=list1;
while(np)
{
inode++;
if(inode==a-1)
start=np;
if(inode==b+1)
end=np;
np=np->next;
}
np=list2;
start->next=list2;
while(np)
{
save=np;
np=np->next;
}
save->next=end;
np=list1;
return np;
}