Time: 6 ms (55.93%), Space: 6.2 MB (98.14%) - LeetHub

This commit is contained in:
Deven
2023-05-28 18:57:00 -04:00
parent a1b7273439
commit f8b9ca177f
@@ -0,0 +1,22 @@
/**
* 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;
}