/**
* 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) {
ListNode* res = head;
ListNode* diff = nullptr;
while(head != nullptr){
diff = head->next;
while(diff !=nullptr && diff->val == head->val){
diff = diff->next;
}
head->next = diff;
head = diff;
}
return res;
}
};