struct ListNode* deleteDuplicates(struct ListNode* head){ int cnt=0; struct ListNode* root=(struct ListNode*)calloc(sizeof(struct ListNode),1); struct ListNode* cur=root; root->next=head; while(head){ cnt++; if(head->next==NULL || head->next->val!=head->val){ if(cnt<2){ cur->next=head; cur=head; } cnt=0; } head=head->next; } cur->next=NULL; return root->next; }
原文:https://www.cnblogs.com/ganxiang/p/14129222.html