* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
class Solution {
public:
/**
*
* @param head ListNode类
* @return ListNode类
*/
ListNode* deleteDuplicates(ListNode* head) {
// write code here
if(!head||!head->next)
return head;
ListNode *pre,*cur;
cur=head;
map<int,int>m;
while(head){
if(m[head->val]){
pre->next=head->next;
head=head->next;
continue;
}
else {
m[head->val]=1;
}
pre=head;
head=head->next;
}
return cur;
}
};