mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08: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;
|
|
}
|