/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution {//on my own public: ListNode* deleteDuplicates(ListNode* head) { ListNode* cur=head; ListNode* ret1=head; while(cur){ while(cur->next!=NULL && cur->val==cur->next->val){ cur=cur->next; } ret1->next=cur->next; ret1=cur->next; cur=cur->next; } return head; } };