标签:
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *deleteDuplicates(ListNode *head) { ListNode *Head = (ListNode *)malloc(sizeof(ListNode)); ListNode *tail = Head,*p1 = head; while(p1){ while(p1->next&&p1->val == p1->next->val) p1 = p1->next;//去重 tail->next = p1; tail = tail->next; p1 = p1->next; } return Head->next; } };
Remove Duplicates from Sorted List
标签:
原文地址:http://www.cnblogs.com/llei1573/p/4337309.html