Created
December 26, 2018 04:41
-
-
Save kanrourou/7b38ddce4814c6f0afe398f30a4a9bf3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Definition for singly-linked list. | |
* struct ListNode { | |
* int val; | |
* ListNode *next; | |
* ListNode(int x) : val(x), next(NULL) {} | |
* }; | |
*/ | |
class Solution { | |
public: | |
ListNode* deleteDuplicates(ListNode* head) { | |
auto curr = head; | |
while(curr) | |
{ | |
auto next = curr->next; | |
while(next && curr->val == next->val) | |
next = next->next; | |
curr->next = next; | |
curr = curr->next; | |
} | |
return head; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment