mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
22 lines
461 B
C
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;
|
|
|
|
} |