【LeetCode】Remove Duplicates from Sorted List
来源:互联网 发布:访客网络会影响网速么 编辑:程序博客网 时间:2024/05/16 14:49
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2
, return 1->2
.
Given 1->1->2->3->3
, return 1->2->3
.
/** * 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 *ret=head; ListNode *pre=head; int flag; while(NULL != pre && NULL != pre->next){ if(pre->val == pre->next->val){ pre->next=pre->next->next; }else{ pre=pre->next; } } return ret; }};
0 0
- Remove Duplicates from Sorted List :from LeetCode
- Leetcode - List - Remove Duplicates from Sorted List
- [leetcode][list] Remove Duplicates from Sorted List
- [leetcode][list] Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List
- [Leetcode] Remove Duplicates from Sorted List II
- LeetCode: Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List II
- leetcode 37: Remove Duplicates from Sorted List
- [leetcode] Remove Duplicates from Sorted List II
- [LeetCode] Remove Duplicates from Sorted List II
- [LeetCode] Remove Duplicates from Sorted List
- [leetcode] Remove Duplicates from Sorted List
- [leetcode] Remove Duplicates from Sorted List II
- [LeetCode]Remove Duplicates from Sorted List
- 程序员如何做SOHO一族接单赚外快呢?
- GitHub 的初始化
- NSPredicate
- C语言中void的作用
- 第六周作业—利用哈夫曼编码英文字母表
- 【LeetCode】Remove Duplicates from Sorted List
- A. Little Elephant and Bits
- OCP 1Z0 051 QUESTION NO: 51
- 献给初学者-DSP入门教程【转】
- 关于在scrum中的一些总结
- HashMap笔试面试题汇总解析
- 安卓Webview引用谷歌web地图
- ATL学习笔记(1):ATL单线程与多线程套间对象引用计数的基础实现
- 车牌识别软件简析及国内各厂家对比数据