mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-15 09:57:09 +00:00
Time: 6 ms (55.93%), Space: 6.2 MB (98.14%) - LeetHub
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user