Remove Duplicates from Sorted List II
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
ListNode* Solution::deleteDuplicates(ListNode* A) { ListNode* dummy = new ListNode(INT_MIN); dummy->next = A; ListNode* runner = dummy; while(runner->next and runner->next->next) { if(runner->next->next->val == runner->next->val) { ListNode* move = runner->next; while(move and move->val == runner->next->val) move = move->next; runner->next = move; } else runner = runner->next; } return dummy->next; }
|