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的更多相关文章

  1. [LeetCode] Remove Duplicates from Sorted List 移除有序链表中的重复项

    Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...

  2. [LeetCode] Remove Duplicates from Sorted List II 移除有序链表中的重复项之二

    Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb ...

  3. 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题要求 ...

  4. [LeetCode] 83. Remove Duplicates from Sorted List 移除有序链表中的重复项

    Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1 ...

  5. [LeetCode] 82. Remove Duplicates from Sorted List II 移除有序链表中的重复项之二

    Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb ...

  6. [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 ...

  7. LeetCode 82. 删除排序链表中的重复元素 II(Remove Duplicates from Sorted List II)

    82. 删除排序链表中的重复元素 II 82. Remove Duplicates from Sorted List II 题目描述 给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中没有 ...

  8. 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 ...

  9. Remove Duplicates from Sorted List ,除去链表中相邻的重复元素

    Remove Duplicates from Sorted List : Given a sorted linked list, delete all duplicates such that eac ...

随机推荐

  1. HTTP生命周期

    HTTP生命周期 Http 请求 AspNet_ISAIP.DLL (ISAPI扩展,独立于站点外,用于可扩展的桥梁), w3wp.exe (net工作进程) IIS6 以上,6以下为aspnet_w ...

  2. Oracle EBS-SQL (WIP-5):检查非标任务本身选上了MRP净值.sql

    SELECT WE.WIP_ENTITY_NAME,            MSI.SEGMENT1,            MSI.DESCRIPTION,            WDJ.CLASS ...

  3. [Django] html 前端页面jQuery、图片等路径加载问题

    严格的说这个话题应该属于一个html前端路径加载问题.为了实现一个局部更新页面的功能,简单了解了一下Ajax.Ajax是一个为了实现浏览器和服务器异步通信功能的模块.严格来说不是一个新的语言,只是JS ...

  4. 500多条Linux信息

    http://www.cnblogs.com/zgqjymx/myposts.html?page=77 http://www.cnblogs.com/zgqjymx/tag/%E5%8E%9F%E5% ...

  5. CreateFile函数详解(确实很详细)

    CreateFile The CreateFile function creates or opens the following objects and returns a handle that ...

  6. 并查集及其简单应用:优化kruskal算法

    并查集是一种可以在较短的时间内进行集合的查找与合并的树形数据结构 每次合并只需将两棵树的根合并即可 通过路径压缩减小每颗树的深度可以使查找祖先的速度加快不少 代码如下: int getfather(i ...

  7. poj3006---素数筛法

    #include <stdio.h> #include <stdlib.h> ];//以后都用宏定义 MAX int main()//如要将包括1000000在内的打表,数组就 ...

  8. sqlplus handbook

    1.直接敲sqlplus并回车就是启动SQL*PLUS,输入user及password将使用户登陆到缺省的数据库. 请输入用户名: 2.sqlplus user/password@SERVICE_NA ...

  9. POJ2186 Popular Cows 【强连通分量】+【Kosaraju】+【Tarjan】+【Garbow】

    Popular Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 23445   Accepted: 9605 Des ...

  10. webView的一些经验总结

    部分内容再录于:http://www.360doc.com/content/14/0611/13/15210553_385676271.shtml 一.    加载资源的速度不慢,但是资源多了,就很慢 ...