Files
leetcode/83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.c
T

22 lines
461 B
C

/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* deleteDuplicates(struct ListNode* head){
struct ListNode *current = head;
while (current) {
struct ListNode *next = current->next;
while (next && current->val == next->val) {
next = next->next;
}
current->next = next;
current = next;
}
return head;
}