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 ...
随机推荐
- K8S存储相关yaml
一.ConfigMap 1.使用目录创建 vim game.properties vim ui.properties 在一个文件夹下创建两个文件,通过以下命令创建 kubectl create con ...
- linux内核启动过程
作者:严哲璟 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 通过qemu以 ...
- spring整合Quartz2持久化任务调度
转摘 https://blog.csdn.net/qwe6112071/article/details/50999386 因为通过Bean配置生成的JobDetail和CronTrigger或Simp ...
- linux中设置虚拟域名
一.打开tomcat安装目录下conf/server.xml这个文件在server.xml文档中找到 </Engine></Service> 接着添加上面添加以下内容(暂时先说 ...
- html5 实例渐变
代码实例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- bzoj1488 [HNOI2009]图的同构 Burnside 引理
题目传送门 bzoj1488 - [HNOI2009]图的同构 bzoj1815 - [Shoi2006]color 有色图(双倍经验) 题解 暴力 由于在做题之前已经被告知是 Burnside 引理 ...
- 一张图理解"Figure", "Axes", "Axis"
Figure is the object with the highest level in the hierarchy. It corresponds to the entire graphical ...
- 解决swagger跨项目或跨程序集注释不显示问题
背景 我们在使用Swagger生成.NET Core Web Api 项目接口文档时候,发现接口的入参和出参的注释是看不见的,如下: 但是我想要结果是这样: 原因分析以及方案 为什么没有显示注释呢,注 ...
- docker 运行jenkins及vue项目与springboot项目(三.jenkins的使用及自动打包vue项目)
docker 运行jenkins及vue项目与springboot项目: 一.安装docker 二.docker运行jenkins为自动打包运行做准备 三.jenkins的使用及自动打包vue项目 四 ...
- SQLServer 链接服务器及同义词
链接服务器 1. openrowse exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc ...