标签:nbsp des node next 返回 题目 tno turn ted
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } }; */ class Solution { public: ListNode* deleteDuplication(ListNode* pHead) { if(!pHead || !pHead->next) return pHead; ListNode *dummy = new ListNode(-1); dummy->next = pHead; ListNode *pre = dummy; ListNode *curr = dummy->next; while(curr && curr->next){ if(curr->val == curr->next->val){ while(curr->next && curr->val == curr->next->val){ curr = curr->next; } pre->next= curr->next; curr = curr->next; } else{ pre = curr; curr = curr->next; } } return dummy->next; } };
标签:nbsp des node next 返回 题目 tno turn ted
原文地址:http://www.cnblogs.com/xiuxiu55/p/6683514.html