mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
14 lines
422 B
C
14 lines
422 B
C
struct ListNode* deleteDuplicates(struct ListNode* head) {
|
|
if(head == NULL)
|
|
return NULL;
|
|
if(head->next && head->val == head->next->val) {
|
|
/* Remove all duplicate numbers */
|
|
while(head->next && head->val == head->next->val)
|
|
head = head -> next;
|
|
return deleteDuplicates(head->next);
|
|
} else {
|
|
head->next = deleteDuplicates(head->next);
|
|
}
|
|
return head;
|
|
}
|