当前位置:网站首页>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;
}
};边栏推荐
- Cloud security daily 220630: the IBM data protection platform has found an arbitrary code execution vulnerability, which needs to be upgraded as soon as possible
- 2022-2028 global weight loss ginger tea industry research and trend analysis report
- left join左连接匹配数据为NULL时显示指定值
- How to edit special effects in VR panorama? How to display detailed functions?
- Excuse me, does Flink support synchronizing data to sqlserver
- ABAQUS 2022 latest edition - perfect realistic simulation solution
- Using Excel to quickly generate SQL statements
- P4学习——p4runtime
- 2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report
- 2022-2028 global elevator emergency communication system industry research and trend analysis report
猜你喜欢

Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)

2022-2028 global rampant travel industry research and trend analysis report

20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking

Bugku CTF daily one question dark cloud invitation code

IFLYTEK active competition summary! (12)

写给 5000 粉丝的一封信!

Line number of Jenkins pipeline script execution exception

HDU 2488 A Knight's Journey(DFS)

The principle of journal node

优质的水泵 SolidWorks模型素材推荐,不容错过
随机推荐
IBL预计算的疑问终于解开了
Mindjet mindmanager2022 mind map decompression installer tutorial
P4学习——p4runtime
[designmode] factory pattern
20220215-ctf-misc-buuctf-einstein-binwalk analyze picture-dd command separate zip file -- look for password in picture attribute
CTF tool (1) -- archpr -- including installation / use process
C language file operation for conquering C language
双链表:初始化 插入 删除 遍历
Kubernetes ---- pod configuration container start command
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
Self examination before school starts
Examples of topological sequences
Basic knowledge of Embedded Network - introduction of mqtt
What SQL statements are supported for data filtering
Confirm() method of window
ABAQUS 2022 latest edition - perfect realistic simulation solution
2022-2028 global public address fire alarm system industry research and trend analysis report
Tibetan poem PTA
2022-2028 global carbon fiber room scraper system industry research and trend analysis report
【日常记录】——对BigDecimal除法运算时遇到的Bug