当前位置:网站首页>LeetCode 83. Delete duplicate elements in the sorting linked list
LeetCode 83. Delete duplicate elements in the sorting linked list
2022-07-02 06:10:00 【Great white sheep_ Aries】
Title Description
83. Delete duplicate elements from the sort list
solution
A set of fast and slow pointers is done
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if (head == nullptr) return nullptr;
ListNode* slow = head;
ListNode* fast = head;
while (fast != nullptr)
{
if (fast->val != slow->val)
{
slow->next = fast;
slow = slow->next;
}
fast = fast->next;
}
slow->next = nullptr;
return head;
}
};
边栏推荐
- Community theory | kotlin flow's principle and design philosophy
- Summary of MySQL constraints
- Talking about MySQL database
- Stc8h8k series assembly and C51 actual combat - keys allow key counting (using falling edge interrupt control)
- 495. Timo attack
- Redis key value database [advanced]
- Contest3147 - game 38 of 2021 Freshmen's personal training match_ 1: Maximum palindromes
- Redis key value database [primary]
- Common websites for Postgraduates in data mining
- Problems encountered in uni app development (continuous update)
猜你喜欢

ZABBIX server trap command injection vulnerability (cve-2017-2824)

ROS2----LifecycleNode生命周期节点总结

Summary of MySQL constraints

Google Play Academy 组队 PK 赛,正式开赛!

Little bear sect manual query and ADC in-depth study

复杂 json数据 js前台解析 详细步骤《案例:一》

Classic literature reading -- deformable Detr

Data playback partner rviz+plotjuggler

MySQL transaction and isolation level
![[C language] simple implementation of mine sweeping game](/img/f7/15d561b3c329847971cabd4708c851.png)
[C language] simple implementation of mine sweeping game
随机推荐
Deep learning classification network -- vggnet
Talking about MySQL database
servlet的web.xml配置详解(3.0)
经典文献阅读之--Deformable DETR
借力 Google Cloud 基础设施和着陆区,构建企业级云原生卓越运营能力
Redis Key-Value数据库 【高级】
Lambda 表达式 和 方法引用
Detailed steps of JS foreground parsing of complex JSON data "case: I"
Ros2 --- lifecycle node summary
On Web server
Redis Key-Value数据库 【秒杀】
STC8H8K系列汇编和C51实战——按键允许按键计数(利用下降沿中断控制)
Flutter 混合开发: 开发一个简单的快速启动框架 | 开发者说·DTalk
CNN可视化技术 -- CAM & Grad-CAM详解及pytorch简洁实现
Shenji Bailian 3.53-kruskal
MUI底部导航的样式修改
神机百炼3.52-Prim
How to use mitmproxy
Zhuanzhuanben - LAN construction - Notes
Stc8h8k series assembly and C51 actual combat - digital display ADC, key serial port reply key number and ADC value