// 84ms
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 8 */ 9 class Solution { 10 public: 11 ListNode *deleteDuplicates(ListNode *head) { 12 // Start typing your C/C++ solution below 13 // DO NOT write int main() function 14 ListNode *p,*q; 15 p=head; 16 while(p) 17 { 18 while((p->next)&&(p->val==p->next->val)) 19 { 20 p->next=p->next->next; 21 } 22 p=p->next; 23 } 24 return head; 25 } 26 };