标签:val next rem remove from list head ica public
/**
?* 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) {
? ? ? ? ListNode *root=head;
? ? ? ? while(head!=NULL)
? ? ? ? {
? ? ? ? ? ? while(head->next!=NULL&&head->val==head->next->val)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? head->next=head->next->next;
? ? ? ? ? ? }
? ? ? ? ? ? head=head->next;
? ? ? ? }
? ? ? ? return root;
? ? }
};
83.Remove Duplicates from Sorted List
标签:val next rem remove from list head ica public
原文地址:https://www.cnblogs.com/smallredness/p/10676005.html