/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* deleteDuplication(ListNode* head) {
if(!head) return NULL;
int numbers[110] = {0};
for(ListNode* i = head; i != NULL; i = i->next)
numbers[i->val]++;
ListNode* fake = new ListNode(-1);
fake->next = head;
ListNode* i = fake;
while (i != NULL) {
while (i->next != NULL && numbers[i->next->val] > 1) {
i->next = i->next->next;
}
i = i->next;
}
return fake->next;
}
};