LeetCode Linked List Easy 83. Remove Duplicates from Sorted List
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的更多相关文章
- leetcode修炼之路——83. Remove Duplicates from Sorted List
哈哈,我又来了.昨天发现题目太简单就没有放上来,今天来了一道有序链表的题.题目如下: Given a sorted linked list, delete all duplicates such th ...
- 【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 ...
- 【Leetcode】【Easy】Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- 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题要求 ...
- 83. Remove Duplicates from Sorted List【easy】
83. Remove Duplicates from Sorted List[easy] Given a sorted linked list, delete all duplicates such ...
- <LeetCode OJ> 83. Remove Duplicates from Sorted List
83. Remove Duplicates from Sorted List Total Accepted: 94387 Total Submissions: 264227 Difficulty: E ...
- [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】#83. Remove Duplicates from Sorted List
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- 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 ...
随机推荐
- C# List和DataTable的相互转换
1.List转DataTable /// <summary> /// list to datatable /// </summary> /// <typeparam na ...
- 【LeetCode】抽样 sampling(共4题)
第一部分 水塘抽样 reservoir sampling 水塘抽样的原理:(应该开一篇新文章)pssss [382]Linked List Random Node (2018年11月15日,新算法) ...
- Flutter-ListView
return Container( child: ListView( children: <Widget>[ Column( children: <Widget>[ Conta ...
- webRTC脱坑笔记(三)— webRTC API之RTCPeerConnection
RTCPeerConnection API是每个浏览器之间点对点连接的核心,RTCPeerConnection是WebRTC组件,用于处理对等体之间流数据的稳定和有效通信. RTCPeerConnec ...
- CPU性能优化
原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11521331.html CPU性能指标 根据指标找工具 根据工具查指标 top.vmstat 和 pi ...
- java上传附件含有%处理或url含有%(URLDecoder: Illegal hex characters in escape (%) pattern - For input string)
在附件名称中含有%的时候,上传附件进行url编码解析的时候会出错,抛出异常: Exception in thread "main" java.lang.IllegalArgumen ...
- Windows下安装的Jenkins修改默认端口号8080(修改配置文件的方式)
1.首先在Windows下找到Jenkins安装目录.2.在安装目录下找到jenkins.xml文件 3.打开jenkins.xml文件,找到httpPort=8080 4.修改成你想要的端口号即可, ...
- python练习题自己实现一个字符串的find函数
# 第五题:自己实现一个字符串的find函数 # 1.在一个字符串中查找另一个字符串 # 2.找到了返回第一次出现的位置 # 3.没找到返回-1 # 4.参数s1为源字符串,参数s2为要查找的字符串 ...
- B-Tree, B+Tree, B*树介绍
[数据结构]B-Tree, B+Tree, B*树介绍 转 [数据结构]B-Tree, B+Tree, B*树介绍 [摘要] 最近在看Mysql的存储引擎中索引的优化,神马是索引,支持啥索引.全是 ...
- CentOS7 图形化方式安装Oracle 18c 安装配置
下载 Oracle 数据库,zip 包 https://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.h ...