c++
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if(head==NULL)
return head;
ListNode* term = head;
int pre = term->val;
while(term->next!=NULL)
{
if(term->next->val == pre)
{
ListNode* temp = term->next->next;
term->next = temp;
continue;
}
pre = term->next->val;
term = term->next;
}
return head;
}
};