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