Remove Duplicates from Sorted List II
来源:互联网 发布:手机怎么上传淘宝图片 编辑:程序博客网 时间:2024/06/11 06:00
/** * 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) { if(head==NULL || head->next==NULL) return head; ListNode* now=head; ListNode* newHead=new ListNode(-1); ListNode* pre=newHead; newHead->next=head; while(now && now->next) { if(now->val == now->next->val) { while(now->next && now->val == now->next->val) { now=now->next; } pre->next=now->next; now=now->next; } else { pre=now; now=now->next; } } head=newHead->next; delete(newHead); return head; }};
0 0
- LeetCode: Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List II
- LeetCode: Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List II
- [leetcode] Remove Duplicates from Sorted List II
- [LeetCode] Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- [leetcode] Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- Remove duplicates from sorted list II
- Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- [LeetCode]Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- Remove Duplicates from Sorted List II
- [leetcode]Remove Duplicates from Sorted List II
- Effective C++ 条款38
- CentOS6.4 安装配置iptables
- 设计模式 外观模式 一键电影模式
- Djanjo学习____Pagination
- 木瓜妮子多媒体开发教程---第四天---Android下图像空间滤波
- Remove Duplicates from Sorted List II
- MySQL分页查询
- Android中px、dp、dip、sp详解
- 避免TableViewCell重叠的问题
- 微软100题(53)字符串的排列
- MySQL之——新安装的MySQL必须调整的10项配置(插曲)
- Median of Two Sorted Arrays
- 回收站功能在 Linux 中的实现
- 工厂方法--创建型模式(Factory method)