mirror of
https://github.com/TheAlgorithms/C
synced 2025-04-23 05:52:21 +03:00
14 lines
276 B
C
14 lines
276 B
C
|
|
struct ListNode *deleteDuplicates(struct ListNode *head)
|
|
{
|
|
struct ListNode *cur = head;
|
|
while (cur && cur->next)
|
|
{
|
|
if (cur->val == cur->next->val)
|
|
cur->next = cur->next->next;
|
|
else
|
|
cur = cur->next;
|
|
}
|
|
return head;
|
|
}
|