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. leetcode 001

    1 Two Sum Difficulty: Easy The Link: https://leetcode.com/problems/two-sum/description/ Description ...

  2. oracle的分析函数over

    参考地址:https://www.cnblogs.com/chinas/p/7058771.html?utm_source=itdadao&utm_medium=referral#_lab2_ ...

  3. canvas 绘制三次贝塞尔曲线

    代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...

  4. java 比较两个日期大小(2) 用before(), after()

    调试代码,我就不整理了,记下after()  before() 觉得这张图好美,从人家的博客上截的,找不到链接了

  5. Unit Testing of Classes in Java

    Every class can have a main method. That is a handy trick for unit testing of classes. For example, ...

  6. boost phoenix

    In functional programming, functions are objects and can be processed like objects. With Boost.Phoen ...

  7. linux学习-常用文本处理命令

    1.文本处理命令 (1) tr 转换或删除字符 tr [OPTION]...SET1 SET2 选项: -c 取SET1字符串的补集 -d 删除属于SET1中的字符 -s 把连续重复出现的字符以单独一 ...

  8. JSON对象及方法

    1.JSON JSON 包括 JSON 字符串和 JSON 对象.JSON 通常用于与服务端交换数据,在给服务器接收和发送数据时用的都是字符串,可以是 JSON 字符串或者一般的键值对字符串.把Jav ...

  9. 【Java】maven打包源码、依赖插件

    <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactI ...

  10. Security基础(三):OpenSSL及证书服务、邮件TLS/SSL加密通信

    一.OpenSSL及证书服务 目标: 本案例要求熟悉OpenSSL工具的基本使用,完成以下任务操作: 使用OpenSSL加密/解密文件 搭建企业自有的CA服务器,为颁发数字证书提供基础环境 方案: 使 ...