1.删除链表中的节点
void deleteNode(struct ListNode* node) {
node->val=node->next->val;
node->next=node->next->next;
}
2.反转链表
struct ListNode* reverseList(struct ListNode* head){
struct ListNode *pre =NULL;
struct ListNode *curr = head;
while(curr)
{
head=curr->next;
curr->next=pre;
pre=curr;
curr=head;
}
return pre;
}
3.合并两个链表(递归)
struct ListNode* mergeTwoLists(struct ListNode* l1, struct ListNode* l2){
if(l1==NULL)
return l2;
if(l2==NULL)
return l1;
if(l1->val<l2->val)
{l1->next=mergeTwoLists(l1->next,l2);
return l1;
}
else
{
l2->next=mergeTwoLists(l1,l2->next);
return l2;
}
}