标签:nod 删除 *** ret ted class else cat next
ListNode *deleteDuplicates(ListNode *head) {
if (head == nullptr || head->next == nullptr)
return head;
ListNode prehead(-1);
prehead.next = head;
head = &prehead;
ListNode *left, *right;
while (head->next) {
left = head->next;
right = left;
while (right->next && right->next->val == left->val)
right = right->next;
if (left == right)
head = head->next;
else
head->next = right->next;
}
return prehead.next;
}
标签:nod 删除 *** ret ted class else cat next
原文地址:https://www.cnblogs.com/INnoVationv2/p/10176351.html