当前位置:网站首页>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;
}
}
}
边栏推荐
猜你喜欢
framework源码读后感
【渗透工具】浏览器数据导出工具
字节技术面都过了,薪资都谈好了20K*13结果还是被刷了,问HR原因是。。。
The technical aspects of the byte have been passed, and the salary has been negotiated for 20K*13, but the result is still being brushed. I asked the HR why...
Golden Warehouse Database KingbaseGIS User Manual (6.5. Geometry Object Editing Function)
ES6 从入门到精通 # 12:数组的扩展方法一
ES6 Beginner to Mastery #15: Generator Usage
go语言的并发原理(goroutine)
Description of AirFlow
大龄测试员刚迈过了 35 岁这个“坎儿”,和大家说点儿心里话
随机推荐
Kubernetes 开发环境比对
Creo5.0入门教程赠素材
[SUCTF 2019]CheckIn (.htaccess和.user.ini)
NTU General Database-Gbase-8a-Learning-04-Deploying Distributed Clusters
蔚来杯2022牛客暑期多校训练营7 CFGJ
【集训DAY3】中位数
router路由
考柏的感慨
【obs】obsqsv11 硬编 及与metartc codec对比
基于ABP的AppUser对象扩展
ES6 从入门到精通 # 13:数组的扩展方法二
【集训DAY4】矩形【线段树】
ES6 Beginner to Mastery #13: Extension Methods for Arrays 2
WPF DataGrid 使用数据模板
CAD 截断线段
巴比特 | 元宇宙每日必读:国内首个数字人产业专项支持政策发布,2025年北京数字人产业规模将破500亿元...
When knowledge and action are one
MATLB|And her ups and downs and finally reached the peak of life [Romantic Journey]
JSON对象和字符串相互转化
重估HR SaaS:一体化后的新三年