码迷,mamicode.com
首页 > 其他好文 > 详细

83.Remove Duplicates from Sorted List

时间:2019-04-09 12:32:43      阅读:152      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!