83. Remove Duplicates from Sorted List (List)
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
class Solution {
public:
ListNode *deleteDuplicates(ListNode *head) {
if(!head) return head;
ListNode *previous = head;
ListNode *current = head->next;
while(current)
{
if(current->val == previous->val)
{
previous->next = current->next;
}
else
{
previous = previous->next;
}
current = current->next;
}
return head;
}
};
83. Remove Duplicates from Sorted List (List)的更多相关文章
- 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 ...
- 【LeetCode】83 - Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...
- 83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- 【LeetCode】83 - Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- Java [Leetcode 83]Remove Duplicates from Sorted List
题目描述: Given a sorted linked list, delete all duplicates such that each element appear only once. For ...
- leetcode修炼之路——83. Remove Duplicates from Sorted List
哈哈,我又来了.昨天发现题目太简单就没有放上来,今天来了一道有序链表的题.题目如下: Given a sorted linked list, delete all duplicates such th ...
随机推荐
- 基于openresty 的几个开发框架
1. kong api gateway Github: https://github.com/Mashape/kong 2. Lapis web 开发框架 Github: ...
- Dev-C++ 小问题锦集
C++ project cann't debug Your project does not have debugging information, do you want to enable deb ...
- 关于RAS加密中pfx格式提取字符串私钥 (转)
openssl 使用以下命令 如果如果执行出错,请查看是否安装环境或在命令前面加上openssl --提取出来的无法直接使用 pkcs12 -in zhaoshang2.pfx -nocerts -n ...
- Java语言与C语言混合编程(2)--在Java中调用C语言本地库
在上一篇文章中介绍了Java语言中的native关键字,以及Java语言调用C语言的编译生成本地动态链接库(DLL)实现加法运算的小例子,本文通过一个更加详细的例子,深入讲解Java语言调用C语言的函 ...
- table tr列 鼠标经过时更改背景颜色
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- buntu12.10 64位 + android-ndk-r9 编译ffmpeg遇到的问题
android-ndk-r8d/build/core/build-binary.mk:41: *** target file `clean' has both : and :: entries. ...
- 杂项:Vue.js
ylbtech-杂项:Vue.js Vue.js(读音 /vjuː/, 类似于 view)是一个构建数据驱动的 web 界面的渐进式框架.Vue.js 的目标是通过尽可能简单的 API 实现响应的数据 ...
- Nginx限制服务地址
今天要在Nginx上设置禁止通过IP访问服务器,只能通过域名访问,这样做是为了避免别人把未备案的域名解析到自己的服务器IP而导致服务器被断网,从网络上搜到以下解决方案. 我们在使用的时候会遇到很多的恶 ...
- 使用exe4j把java程序生成可执行的.exe文件
exe4j可以很容易把一个jar打成exe. 下载地址:http://dl.dbank.com/c0owlopqf8 1.下载的安装文件,里面包含一个注册码生成的工具 2.安装exe4j以及破解(注 ...
- Codeforces-591C题解
一.题目链接 http://codeforces.com/problemset/problem/591/C 二.题意 给定一个只含数字0和1的数组,通过如下方式,变成不再变化的01组合,最少需要操作几 ...