当前位置:网站首页>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;
}
};
边栏推荐
- Vmware16 installing win11 virtual machine (the most complete step + stepping on the pit)
- 2022-2028 global electric yacht industry research and trend analysis report
- Redis - sentinel mode
- NE555波形发生器手把手教程之NE555内部结构(一)
- CMU15445 (Fall 2019) 之 Project#1 - Buffer Pool 详解
- When is it appropriate to replace a virtual machine with a virtual machine?
- [untitled]
- CentOS installation starts redis
- 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
- Oracle-表的创建与管理
猜你喜欢
Gateway service gateway
Two-stage RO: part 1
Redis - cache penetration, cache breakdown, cache avalanche
P4学习——p4runtime
2022-2028 global single travel industry research and trend analysis report
Confirm() method of window
2022-2028 global rampant travel industry research and trend analysis report
PyTorch安装并使用gpu加速
20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking
2022-2028 global plant peptone industry research and trend analysis report
随机推荐
双链表:初始化 插入 删除 遍历
2022-2028 global rotary transmission system industry research and trend analysis report
Basic knowledge of Embedded Network - introduction of mqtt
IBL预计算的疑问终于解开了
File reading and writing for rust file system processing - rust Practice Guide
The programmer's girlfriend gave me a fatigue driving test
Bridge emqx cloud data to AWS IOT through the public network
2022-2028 global ultra high purity electrolytic iron powder industry research and trend analysis report
Wechat official account development (1) introduction to wechat official account
女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
Redis - sentinel mode
Manage edge browser settings (ie mode, homepage binding, etc.) through group policy in the enterprise
Vmware16 installing win11 virtual machine (the most complete step + stepping on the pit)
$watch will not trigger data change - $watch not firing on data change
Ditto set global paste only text shortcuts
What SQL statements are supported for data filtering
优质的水泵 SolidWorks模型素材推荐,不容错过
最长的可整合子数组的长度
Makefile notes (Yiwen Institute makefile)
ABAQUS 2022 software installation package and installation tutorial