The key of this problem is about details especially boundary conditions.
class Solution { public: ListNode *deleteDuplicates(ListNode *head) { if(!head) return NULL; ListNode *p = head; ListNode *p0 = p->next; while(p && p0) { while(p && p0 && p->val == p0->val) { p->next = p0->next; p0 = p0->next; } p = p0; if(p0) p0 = p0->next; } return head; } };
LeetCode "Remove Duplicates from Sorted List",布布扣,bubuko.com
LeetCode "Remove Duplicates from Sorted List"
原文地址:http://www.cnblogs.com/tonix/p/3852509.html