标签:for ret 算法 class href duplicate turn ted etc
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if(head == NULL) return head;
ListNode *prev = head;
for(ListNode *cur = prev->next; cur != NULL; cur = cur->next){
if(prev->val == cur->val){
prev->next = cur->next;
}else{
prev = cur;
}
}
return head;
}
};
[LeetCode] 83. Remove Duplicates from Sorted List
标签:for ret 算法 class href duplicate turn ted etc
原文地址:https://www.cnblogs.com/wengle520/p/12311982.html