当前位置:网站首页>Leetcode83. 删除排序链表中的重复元素
Leetcode83. 删除排序链表中的重复元素
2022-08-09 23:32:00 【Java全栈研发大联盟】
题目传送地址: https://leetcode.cn/problems/remove-duplicates-from-sorted-list/
运行效率
代码如下:
class Solution {
public static ListNode deleteDuplicates(ListNode head) {
//处理边界情况
if (head == null || head.next == null) {
return head;
}
//递归解法
ListNode listNode = deleteDuplicates(head.next);
if (listNode.val == head.val) {
return listNode;
}else{
head.next=listNode;
return head;
}
}
}
边栏推荐
- 【数据存储】signed,unsigned到底怎么区分?如何计算?
- MATLB|And her ups and downs and finally reached the peak of life [Romantic Journey]
- 漫谈缺陷管理的自动化实践方案
- 重估HR SaaS:一体化后的新三年
- Wireshark classic practice and interview 13-point summary
- Creo5.0 introductory tutorial free material
- JSP简介
- The older tester has just passed the "hurdle" of being 35 years old, and I want to tell you something from my heart
- Redis-基本介绍/linux下环境配置/配置文件
- GoLang 使用 goroutine 停止的几种办法
猜你喜欢
![[C language] In-depth understanding of pointers and arrays (issue 4)](/img/22/ad31b47bb8cc1722121959efddefd5.png)
[C language] In-depth understanding of pointers and arrays (issue 4)

Redis 非关系型数据库学习(一) ---- Redis 的安装

【云原生】Kubernetes编排工具精讲

framework源码读后感

ES6 Beginner to Mastery #15: Generator Usage

LSTM-based distributed energy generation prediction (Matlab code implementation)

为什么不建议你在 Docker 中跑 Mysql ?

分布式数据库难题(三):数据一致性

今日睡眠质量记录61分

ES6 从入门到精通 # 15:生成器 Generator 的用法
随机推荐
【C语言】通讯录《静态内存版本》
经济衰退即将来临前CIO控制成本的七种方法
【SSL集训DAY2】有趣的数【数位DP】
RebatMq消息中间件(一) 各个中间件介绍
数字孪生电力系统,可视化应用实现科学调度的电子设备
【数据存储】signed,unsigned到底怎么区分?如何计算?
NTU General Database-Gbase-8a-Learning-04-Deploying Distributed Clusters
Today's sleep quality record 61 points
分布式数据库难题(三):数据一致性
【SSL集训DAY3】控制棋盘【二分图匹配】
【集训DAY3】阶乘【数学】
Alibaba Cloud SMS Service Activation
AppUser object extension based on ABP
南大通用数据库-Gbase-8a-学习-04-部署分布式集群
ES6 从入门到精通 # 14:迭代器 Iterator 的用法
WPF DataGrid using data templates
Distributed database problem (2): data replication
Description of AirFlow
Impala 疑问
ES6 Beginner to Mastery #15: Generator Usage