Description

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

Example 1:

Input: ->->
Output: ->

Example 2:

Input: ->->->->
Output: ->->

问题描述:给定一个已排序链表,移除重复元素

代码:

 public ListNode DeleteDuplicates(ListNode head) {
ListNode l = head;
while(l != null && l.next != null){ if(l.val == l.next.val){
l.next = l.next.next;
}else{
l = l.next;
}
}
return head;
}

LeetCode Linked List Easy 83. Remove Duplicates from Sorted List的更多相关文章

  1. leetcode修炼之路——83. Remove Duplicates from Sorted List

    哈哈,我又来了.昨天发现题目太简单就没有放上来,今天来了一道有序链表的题.题目如下: Given a sorted linked list, delete all duplicates such th ...

  2. 【Leetcode】【Easy】Remove Duplicates from Sorted Array

    Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...

  3. 【Leetcode】【Easy】Remove Duplicates from Sorted List

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

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

  5. 83. Remove Duplicates from Sorted List【easy】

    83. Remove Duplicates from Sorted List[easy] Given a sorted linked list, delete all duplicates such ...

  6. <LeetCode OJ> 83. Remove Duplicates from Sorted List

    83. Remove Duplicates from Sorted List Total Accepted: 94387 Total Submissions: 264227 Difficulty: E ...

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

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

  8. 【一天一道LeetCode】#83. Remove Duplicates from Sorted List

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...

  9. C# 写 LeetCode easy #26 Remove Duplicates from Sorted Array

    26.Remove Duplicates from Sorted Array Given a sorted array nums, remove the duplicates in-place suc ...

随机推荐

  1. Spark 读取HBase数据

    Spark1.6.2 读取 HBase 1.2.3 //hbase-common-1.2.3.jar //hbase-protocol-1.2.3.jar //hbase-server-1.2.3.j ...

  2. day07作业猜年龄游戏

    # 给定年龄,用户可以猜三次年龄 # # 年龄猜对,让用户选择两次奖励 # # 用户选择两次奖励后退出 get_prize_dict = {} # 获取的奖品信息 age = 18 inp_count ...

  3. ci常量

    1. ENVIRONMENT产品的环境,有3种环境,分别是: development开发环境 testing测试环境 production生产环境 2. SELFCI的主入口文件名称 例如我的是: i ...

  4. 英语单词cylindern

    cylindern 来源——fdisk -l [root@centos65 ~]# fdisk -l Disk /dev/sda: 214.7 GB, 214748364800 bytes 255 h ...

  5. eval函数让我忧伤

    今天首次接触这个eval函数,让我忧伤了一把.我把当成字符串拼接,结果错得天远地远.大体情况是下面这句代码,一个劲的给我报NameError: name 'qinfeng' is not define ...

  6. python作业习题集锦

    1. 登录作业: 写一个登录程序,登录成功之后,提示XXX欢迎登录,登录失败次数是3次,要校验一下输入为空的情况 for i in range(3): username=input('username ...

  7. React学习笔记-生命周期函数

    定义: 生命周期函数指在某一个时刻组件会自动调用执行的函数

  8. java 标准输入输出流,打印流,数据流

    1 package stream; import static org.junit.Assert.assertNotNull; import java.io.BufferedReader; impor ...

  9. LINUX时间服务器搭建

    一. 因 为工作需要,偶需要将搭建一个NTP服务器来进行时间同步的测试,在公司里一直以为非常的难搭建,也是刚刚工作的缘故,就等正导师给帮着弄一台服务器,结 果导师给了我一个系统叫Fedora,让我偶自 ...

  10. datastudion 资源导入python包,编写模块

    学习文档,不懂再问. https://help.aliyun.com/document_detail/74423.html?spm=a2c4g.11186623.6.688.72635debHqgkV ...