1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
class Solution { public: ListNode* removeDuplicateNodes(ListNode* head) { auto point = head; while(point) { auto pre = point; auto cur = point->next; while(cur) { if(cur->val == point->val) { pre->next = cur->next; cur = cur->next; }else { pre = pre->next; cur = cur->next; } } point = point->next; } return head; } };
|