struct ListNode* deleteDuplicates(struct ListNode* head ) { if(head == NULL) return NULL; struct ListNode* cur = head; while(cur->next) { struct ListNode* next = cur->next; if(cur->val == next->val) { cur->next = next->next; free(next); } else { cur = cur->next; } } return head; }