记录一下删除重复单链表接点:
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* deleteDuplicates(struct ListNode* head) {
struct ListNode *p = head;
if (p==NULL)
return head;
while(p->next)
{
if(p->val == p->next->val)
{
p->next = p->next->next; //如果相等,指向下一节点。
}
else
p = p->next;
}
return head;
}