首页 > 其他 > 详细

LeetCode() Remove duplicates from sorted list II

时间:2015-11-29 00:53:26      阅读:270      评论:0      收藏:0      [点我收藏+]
 ListNode* dummy = new ListNode(0); //必须要加上 new ListNode(0); 否则有错误。
        dummy->next = head;
        head = dummy;
        while(head->next && head->next->next) {
            if(head->next->val == head->next->next->val) {
                int value = head->next->val;
                while(head->next && head->next->val == value) {
                    head->next = head->next->next;
                }
            } else {
                head = head->next;
            }
        }
        return dummy->next;

  有时候应换一种思路。

LeetCode() Remove duplicates from sorted list II

原文:http://www.cnblogs.com/yanqi110/p/5003795.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!