class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
ListNode* res = head;
while(head != NULL){
if(head->next == NULL){
break;
}
while(head->val == head->next->val){
head->next = head->next->next;
if(head->next == NULL) break;
}
head = head->next;
}
return res;
}
};