当前位置:网站首页>剑指 Offer 18. 删除链表的节点
剑指 Offer 18. 删除链表的节点
2022-07-01 00:32:00 【anieoo】
原题链接:剑指 Offer 18. 删除链表的节点
solution:
class Solution {
public:
ListNode* deleteNode(ListNode* head, int val) {
ListNode *dummy = new ListNode(-1); //虚拟头结点
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;
}
};边栏推荐
- [DaVinci developer topic] -37- detail IRV: introduction to inter runnable variable + configuration
- 2022-2028 global electric yacht industry research and trend analysis report
- 2022-2028 global ethylene oxide scrubber industry research and trend analysis report
- 2022就要过去一半了,挣钱好难
- Deployment of mini version message queue based on redis6.0
- Luogu p1168 median
- Operation record of reinitialization instance of Dameng database
- Confirm() method of window
- On the application of cluster analysis in work
- Vulnerability discovery - App application vulnerability probe type utilization and repair
猜你喜欢

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

How does the VR cloud exhibition hall bring vitality to offline entities? What are the functions?

In depth understanding of jetpack compose kernel: slottable system

2022-2028 global capsule shell industry research and trend analysis report

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

Redis - sentinel mode

C language file operation for conquering C language

Redis - how to understand publishing and subscribing

2022-2028 global 3D printing ASA consumables industry research and trend analysis report

left join左连接匹配数据为NULL时显示指定值
随机推荐
"Experience" my understanding of user growth "new users"
In depth understanding of jetpack compose kernel: slottable system
[untitled]
The programmer's girlfriend gave me a fatigue driving test
What should I do without 50W bride price
Using Excel to quickly generate SQL statements
The principle and related problems of acid in MySQL
What value should testers play in requirements review? Two minutes will stop you from being stupid
JS bubble sort and select sort
Luogu p1168 median
2022-2028 global carbon fiber room scraper system industry research and trend analysis report
The college entrance examination in 2022 is over. Does anyone really think programmers don't need to study after work?
How to specify the number of cycles in JSTL- How to loop over something a specified number of times in JSTL?
2022-2028 global ultra high purity electrolytic iron powder industry research and trend analysis report
The difference between union and union all in MySQL
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
Mysql database query optimization
Date类的实现
20220215 CTF misc buuctf the world in the mirror the use of stegsolve tool data extract
Redis - how to understand publishing and subscribing