开始首次自写,可能这个比较简单吧.
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* deleteDuplicates(struct ListNode* head){
if(head==NULL){
return head;
}
struct ListNode* dummy=head;
struct ListNode* pointer=head;
while(pointer->next!=NULL){
if(pointer->val==pointer->next->val){
pointer->next=pointer->next->next;
continue;
}
pointer=pointer->next;
}
return dummy;
}