class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if(!head||!head->next) return head;
auto pre=head;
auto cur=pre->next;
while(pre->next){
if (cur){
if(pre->val==cur->val) cur=cur->next;
else {
pre->next=cur;
pre=pre->next;
cur=cur->next;
}
} else{
pre->next=cur;
}
}
return head;
}
};