LeetCode 83. Remove Duplicates from Sorted List(从有序链表中删除重复节点)
题意:从有序链表中删除重复节点。
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if(head == NULL || head -> next == NULL){
return head;
}
if(head -> val == head -> next -> val){
return deleteDuplicates(head -> next);
}
else{
head -> next = deleteDuplicates(head -> next);
return head;
}
}
};
LeetCode 83. Remove Duplicates from Sorted List(从有序链表中删除重复节点)的更多相关文章
- [LeetCode] 83. Remove Duplicates from Sorted List ☆(从有序链表中删除重复项)
描述 Given a sorted linked list, delete all duplicates such that each element appear only once. Exampl ...
- [LeetCode] 26. Remove Duplicates from Sorted Array ☆(从有序数组中删除重复项)
[LeetCode] Remove Duplicates from Sorted Array 有序数组中去除重复项 描述 Given a sorted array nums, remove the d ...
- [LeetCode] 80. Remove Duplicates from Sorted Array II 有序数组中去除重复项 II
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...
- [LeetCode] 80. Remove Duplicates from Sorted Array II 有序数组中去除重复项之二
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...
- [LeetCode] Remove Duplicates from Sorted Array II 有序数组中去除重复项之二
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For exampl ...
- 026 Remove Duplicates from Sorted Array 从排序数组中删除重复项
给定一个有序数组,你需要原地删除其中的重复内容,使每个元素只出现一次,并返回新的长度.不要另外定义一个数组,您必须通过用 O(1) 额外内存原地修改输入的数组来做到这一点.示例:给定数组: nums ...
- LeetCode 82,考察你的基本功,在有序链表中删除重复元素II
本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是LeetCode专题的第51篇文章,我们来看LeetCode第82题,删除有序链表中的重复元素II(Remove Duplicates ...
- [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有序链表去重
Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1 ...
随机推荐
- 动态设置 layui select 为选中状态
// 当前的select的id $('#type').val('你的value值'); //更新全部 layui.form.render();
- C++ string类的使用
C++ string的使用 在了解如何使用string类之前,我们先来看看C语言中使用字符串有多麻烦: 调用头文件:cstring 定义一个C字符串: char str1[51]="Hell ...
- AppBoxFuture: Sql存储的ORM查询示例
上篇介绍集成第三方Sql数据库时未实现如导航属性.子查询等功能,经过大半个月的努力作者初步实现了这些功能,基本上能满足80%-90%查询需求,特别复杂的查询可以用原生sql来处理,下面分别示例介绍 ...
- ENS中文文档系列之三 [ ENS常见问题 ]
原文地址:https://ensuser.com/docs/frequently-asked-questions.html更多最新信息,请前往 ENS 中文服务站点:ENSUser 关于 ENS 注册 ...
- Could not find result map com.youotech.tl_cons_credit_rating.entity.Result
后端报错如下: java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.yo ...
- [转]工作量证明(PoW)权益证明(PoS)和委任权益证明(DPoS)区别
原文链接 Both in the glossary and in some of our previous posts we've touched on mining and the two main ...
- [Linux kali] Kali KDE桌面安装中文输入法 不能登录系统
#开始 第一次实体机上面安装kali的KDE桌面版本 结果就遇到了很多的BUG 比如这次就是安装中文输入法有问题 这次安装的是fcitx框架的 尝试了 谷歌输入法 还有搜狗输入法 都有这个问题 也就是 ...
- IIS-反向代理简介
参考:https://www.williamlong.info/archives/5353.html 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后 ...
- RTT学习之RTC设备
RTC: 目前系统内只允许存在一个 RTC 设备,且名称为 "rtc",所以不用查找设备 启用 Soft RTC (软件模拟 RTC),对无硬件RTC 启用 NTP 时间自动同步, ...
- html解析のBeautifulSoup
引子: 使用python爬虫对爬取网页进行解析的时候,如果使用正则表达式,有很多局限,比如标签中出现换行,或者标签的格式不规范,都有可能出现取不到数据,BeautifulSoup作为一个专门处理htm ...