RJ Trujillo d9b9bbd4f5 leetcode: Address readability of a few cases, and fix 283
The for loop utilized in 283 was improperly structured as 'start'
was no declared as the value to index.

Also, make the other cases more readable.

Signed-off-by: RJ Trujillo <certifiedblyndguy@gmail.com>
2019-10-04 17:24:30 -06:00

16 lines
438 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;
}