题目描述:
首刷自解:
ListNode* deleteDuplicates(ListNode* head) {
if (head == nullptr) return head;
ListNode *cur = head;
while (cur->next != nullptr)
{
if (cur->val == cur->next->val)
cur->next = cur->next->next;
else
cur = cur->next;
}
return head;
}