当前位置:网站首页>Sword finger offer 18 Delete the node of the linked list
Sword finger offer 18 Delete the node of the linked list
2022-07-01 00:40:00 【anieoo】
Original link : The finger of the sword Offer 18. Delete the node of the linked list
solution:
class Solution {
public:
ListNode* deleteNode(ListNode* head, int val) {
ListNode *dummy = new ListNode(-1); // Virtual head node
ListNode *cur = head;
ListNode *pre = dummy;
dummy->next = head;
while(cur != NULL) {
if(cur->val == val) {
pre->next = cur->next;
break;
}
pre = pre->next;
cur = cur->next;
}
return dummy->next;
}
};边栏推荐
- ArrayList分析1-循环、扩容、版本
- 2022-2028 global PTFE lined valve industry research and trend analysis report
- 获取屏幕高度
- Vmware16 installing win11 virtual machine (the most complete step + stepping on the pit)
- When is it appropriate to replace a virtual machine with a virtual machine?
- Random ball size, random motion collision
- 2022-2028 global rotary transmission system industry research and trend analysis report
- 2022-2028 global single travel industry research and trend analysis report
- 20220215-ctf-misc-buuctf-einstein-binwalk analyze picture-dd command separate zip file -- look for password in picture attribute
- What SQL statements are supported for data filtering
猜你喜欢

2022-2028 global electric yacht industry research and trend analysis report

Member management applet actual development 07 page Jump

Ranger plug-in development (Part 2)

20220216 misc buuctf another world WinHex, ASCII conversion flag zip file extraction and repair if you give me three days of brightness zip to rar, Morse code waveform conversion mysterious tornado br

CMU15445 (Fall 2019) 之 Project#1 - Buffer Pool 详解

BeanUtils. Copyproperties() vs. mapstruct

ABAQUS 2022 software installation package and installation tutorial

2022-2028 global herbal diet tea industry research and trend analysis report

What should I do without 50W bride price

Date类的实现
随机推荐
2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report
合适的工作就是好工作
How to edit special effects in VR panorama? How to display detailed functions?
2022-2028 global capsule shell industry research and trend analysis report
C#生成putty格式的ppk文件(支持passphrase)
Error 2059 when Navicat connects to MySQL
2022-2028 global 3D printing ASA consumables industry research and trend analysis report
IBL预计算的疑问终于解开了
Oracle临时表详解
Redis - understand the master-slave replication mechanism
Simple application example of rhai script engine
File reading and writing for rust file system processing - rust Practice Guide
Examples of topological sequences
Rhai - rust's embedded scripting engine
Thoughts on the future of data analysis in "miscellaneous talk"
The full technology stack, full scene and full role cloud native series training was launched to help enterprises build a hard core cloud native technology team
Ranger plug-in development (Part 2)
深度学习的历史
Authentication principle of Ranger plug-in
Teach you how to use Hal library to get started -- become a lighting master