class Solution {
public:
/**
* @param head: The first node of linked list.
* @return: head node
*/
ListNode *deleteDuplicates(ListNode *head) {
ListNode *templete,*templete1;
int x;
templete1=head;
while(head!=NULL)
{
if(head->next==NULL)
{
break;
}
if(head->val==head->next->val)
{
head->next=head->next->next;
}
else
{
head=head->next;
}
}
return templete1;
// write your code here
}
};
水
删除排序链表中的重复元素 - C++
最新推荐文章于 2023-10-19 20:02:20 发布