ListNode *deleteDuplicates(ListNode *head) {
if (head == nullptr || head->next == nullptr)
return head;
ListNode *temp = head;
int save = temp->val;
while (temp->next) {
if (temp->next->val == save)
temp->next = temp->next->next;
else {
save = temp->next->val;
temp = temp->next;
}
}
return head;
}