C++ 代码
class Solution {
public:
ListNode* deleteDuplication(ListNode* head) {
if (head == nullptr || head->next == nullptr)return head;
ListNode* temp = head->next;
while (temp && temp->val == head->val)temp = temp->next;//此时temp->val != head->val;
if (temp == head->next)
head->next = deleteDuplication(head->next);
else
head = deleteDuplication(temp);
return head;
}
};