标签:
struct ListNode* deleteDuplicates(struct ListNode* head) { struct ListNode *p=head; if(!head) return head; while(p&&p->next) { if(p->val==p->next->val) p->next=p->next->next; else p=p->next; } return head; }
要注意考虑1->1->1这种情况,第一个1要和后面比较多次。
链表-remove duplicates from sorted list
标签:
原文地址:http://www.cnblogs.com/summerkiki/p/5272343.html