链表-remove duplicates from sorted list
struct ListNode* deleteDuplicates(struct ListNode* head) {
struct ListNode *p=head;
if(!head)
return head;
while(p&&p->next)
{
if(p->val==p->next->val)
p->next=p->next->next;
else
p=p->next;
} return head; }
要注意考虑1->1->1这种情况,第一个1要和后面比较多次。
链表-remove duplicates from sorted list的更多相关文章
- [LeetCode] Remove Duplicates from Sorted List 移除有序链表中的重复项
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- [LeetCode] Remove Duplicates from Sorted List II 移除有序链表中的重复项之二
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb ...
- leetcode 203. Remove Linked List Elements 、83. Remove Duplicates from Sorted List 、82. Remove Duplicates from Sorted List II(剑指offer57 删除链表中重复的结点)
203题是在链表中删除一个固定的值,83题是在链表中删除重复的数值,但要保留一个:82也是删除重复的数值,但重复的都删除,不保留. 比如[1.2.2.3],83题要求的结果是[1.2.3],82题要求 ...
- [LeetCode] 83. Remove Duplicates from Sorted List 移除有序链表中的重复项
Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1 ...
- [LeetCode] 82. Remove Duplicates from Sorted List II 移除有序链表中的重复项之二
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb ...
- [LeetCode] 82. Remove Duplicates from Sorted List II 移除有序链表中的重复项 II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb ...
- LeetCode 82. 删除排序链表中的重复元素 II(Remove Duplicates from Sorted List II)
82. 删除排序链表中的重复元素 II 82. Remove Duplicates from Sorted List II 题目描述 给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中没有 ...
- LeetCode之“链表”:Remove Duplicates from Sorted List && Remove Duplicates from Sorted List II
1. Remove Duplicates from Sorted List 题目链接 题目要求: Given a sorted linked list, delete all duplicates s ...
- Remove Duplicates from Sorted List ,除去链表中相邻的重复元素
Remove Duplicates from Sorted List : Given a sorted linked list, delete all duplicates such that eac ...
随机推荐
- iOS在Xcode6中添加空模板
1.在Xcode6.0以下版本找到空模板(路径与下方相同). 2.将空模板拖入路径:Macintosh HD ▸ 应用程序 ▸ Xcode(版本号).app ▸ Contents ▸ Develo ...
- 浅谈局域网ARP攻击的危害及防范方法(图)
浅谈局域网ARP攻击的危害及防范方法(图) 作者:冰盾防火墙 网站:www.bingdun.com 日期:2015-03-03 自 去年5月份开始出现的校内局域网频繁掉线等问题,对正常的教育教 ...
- 倒计时 NAN 问题
http://blog.csdn.net/lishangua/article/details/51506821
- ORACLE RAC中一个实例不能随crs自动启动的解决
现象:在两个节点上做CRS的重启,这个实例都不能随CRS的启动而启动.CRS启动后做crs_start -all可以把没启动的资源起来,而且无报错. 分析:去crsd.log中找原因,发现CRS根本就 ...
- linux中fork创建进程讲解(转)
大家知道Linux中创建子进程的一个很好的方法是函数调用fork,但是很多初学者对fork的理解上可能有点困难.我们举个例子来看看fork的用法吧. 大家用fork的时候记住fork是 ...
- ant jsch.jar - 一个错误及解决办法
ant jsch.jar -- 一个异常及解决方法 运行build.xml出现异常: Cause: Could not load a dependent class com/jcraft/jsch/L ...
- [zoj 3774]Power of Fibonacci 数论(二次剩余 拓展欧几里得 等比数列求和)
Power of Fibonacci Time Limit: 5 Seconds Memory Limit: 65536 KB In mathematics, Fibonacci numbe ...
- css3前端工具
随着CSS3的出现,CSS3讨论的话题越来越多了,现在各种教程也是多如牛毛,不比一年前的时候,找个资料要捞遍整个互联网,而且还很难找到自己需要的参考资料.从侧面也说明,CSS3对于前端工程师来说,越来 ...
- CSS ::before 和 ::after 伪元素用法
CSS 有两个说不上常用的伪类 :before 和 :after,偶尔会被人用来添加些自定义格式什么的,但是它们的功用不仅于此.前几天发现了 Creative Link Effects 这个非常有意思 ...
- DropDownList四级联动
前台代码: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="iframe_dro ...