/**
* 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 *tmp=(ListNode*)malloc(sizeof(ListNode));
tmp=head;
while (tmp!=NULL)
{
if(tmp->next!=NULL&&tmp->val==tmp->next->val){
tmp->next=tmp->next->next;
continue;
}
else
{
tmp=tmp->next;
}
}
return head;
}
};
Remove Duplicates from Sorted List
最新推荐文章于 2022-03-29 14:58:09 发布