leetcode 083 —— Remove Duplicates from Sorted List
来源:互联网 发布:顶易软件怎么样 编辑:程序博客网 时间:2024/06/03 22:53
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
.
思路:双指针游走遍历
class Solution {public:ListNode* deleteDuplicates(ListNode* head) {if (!head || !head->next) return head;ListNode *cur = head;ListNode *next = head->next;while (cur&&next){while (next&&cur->val == next->val) //next往后寻找不得cur相同的元素next = next->next;if (cur->next = next){cur = cur->next;next = next->next;}else{cur->next = next;cur = next;if (next)next = next->next;}}return head;}};
0 0
- leetcode 083 —— Remove Duplicates from Sorted List
- LeetCode 083 Remove Duplicates from Sorted List
- 083 Remove Duplicates from Sorted List [Leetcode]
- LeetCode 083 Remove Duplicates from Sorted List
- LeetCode 083 Remove Duplicates from Sorted List
- leetcode 083 Remove Duplicates from Sorted List
- LeetCode 083 Remove Duplicates from Sorted List
- LeetCode——Remove Duplicates from Sorted List
- LeetCode——Remove Duplicates from Sorted List II
- LeetCode——Remove Duplicates from Sorted List
- Python学习——leetcode(Remove Duplicates from Sorted List)
- Remove Duplicates from Sorted List —— Leetcode
- LeetCode——Remove Duplicates from Sorted List
- leetcode 081 —— Remove Duplicates from Sorted List II
- Leetcode——83. Remove Duplicates from Sorted List
- Leetcode Problem.83—Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List :from LeetCode
- Leetcode - List - Remove Duplicates from Sorted List
- android studio编译出错——Failed to resolve: com.android.support:support-v4:22.2.0
- 日经社説 20150804 官民が連携し盗聴に警戒を
- NASM import win32api
- 精通DirectX.3D图形与动画程序设计(王德才 杨关胜 孙玉萍/编著,2007年5月出版)读书摘要(2008.8.4至今)
- SQUID与ATS (Apache Traffic Server) 压力测试
- leetcode 083 —— Remove Duplicates from Sorted List
- MVC Ajax.BeginForm异常提交时,跳转到处理页等问的解决方法
- sql server中的 SET NOCOUNT ON 的含义
- 清除属性clear、可视区域clip、超出范围overflow、可见属性visibility
- 南邮 OJ 1069 生日聚会
- 日经社説 20150804 仮想通貨のルールづくり迫る消失事件
- asp:Repeater数据排序
- CALayer
- linux mount命令详解