当前位置:网站首页>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;
}
};边栏推荐
- NE555波形发生器手把手教程之NE555内部结构(一)
- JS bubble sort and select sort
- 【日常记录】——对BigDecimal除法运算时遇到的Bug
- CTF tool (1) -- archpr -- including installation / use process
- 双链表:初始化 插入 删除 遍历
- 2022-2028 global public address fire alarm system industry research and trend analysis report
- IBL预计算的疑问终于解开了
- Redis - how to understand publishing and subscribing
- Design e-commerce seckill system
- CSDN常用复杂公式模板记录
猜你喜欢

Redis - how to understand publishing and subscribing

SSM integration process (integration configuration, function module development, interface test)

优质的水泵 SolidWorks模型素材推荐,不容错过

2022-2028 global encrypted external hard disk industry research and trend analysis report

Redis - sentinel mode

Unit test concept and purpose

From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years

Redis - cache penetration, cache breakdown, cache avalanche

CentOS install MySQL

Line number of Jenkins pipeline script execution exception
随机推荐
Pytorch auto derivation
CTF tool (1) -- archpr -- including installation / use process
20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking
[designmode] singleton pattern
20220215 CTF misc buuctf the world in the mirror the use of stegsolve tool data extract
Basic data structure of redis
Docsify building a personal minimalist knowledge warehouse
Integer to hexadecimal string PTA
Introduction to ES6 promise, new features of ES7 and es8 async and await
20220215 CTF misc buuctf Xiaoming's safe binwalk analysis DD command separate rar file archpr brute force password cracking
2022-2028 global mobile scanning radiology room industry survey and trend analysis report
[designmode] factory pattern
[untitled]
ABAQUS 2022 latest edition - perfect realistic simulation solution
Quick start of wechat applet -- project introduction
What is the fastest way to import data from HDFS to Clickhouse? Spark is imported through JDBC or HDFS
Luogu p1168 median
2022-2028 global plant peptone industry research and trend analysis report
VR panorama adds contrast function to make the display of differentiation effect more intuitive!
20220215-ctf-misc-buuctf-einstein-binwalk analyze picture-dd command separate zip file -- look for password in picture attribute