当前位置:网站首页>203. 移除链表元素
203. 移除链表元素
2022-06-11 08:55:00 【拽拽就是我】
leetcode力扣刷题打卡
题目:203. 移除链表元素
描述:给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val == val 的节点,并返回 新的头节点 。
解题思路
1、遇见val节点,直接跳过往后走;
原代码##
class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
ListNode *p = new ListNode(-1);
ListNode * NewStart = p;
p->next = head;
while (p->next) {
if (p->next->val == val) p->next = p->next->next;
else p = p->next;
}
return NewStart->next;
}
};
边栏推荐
- En45545-2 R26 vertical combustion test introduction
- Codeworks round 723 (Div. 2)
- File system check of the root filesystem failed
- 一些学习记录i=
- 2、 Rendering camera data
- Port occupancy problem, 10000 ports
- Supplement 2: circle returning to origin
- Codetop - sort odd ascending even descending linked list
- Classical graph theory, depth first and breadth first, topology, prim and krukal, it's time to review
- 预编译,编译,汇编,链接,静态库,动态库都是什么
猜你喜欢

哪些Apple设备支持这次系统更新?来看你的旧Apple设备支持最新系统吗

How to apply for BS 476-7 sample for display? Is it the same as the display

Matlab学习9-图像处理之非线性锐化滤波

leetcode - 460. LFU 缓存

MySQL upgrade

What is concurrent search set? Are you still worried about it? In fact, it is a problem of connected graph, which is not so difficult to understand

What if the copied code format is confused?
![[Clickhouse column] user initialization of new library role](/img/00/a11fb1a8e38ed4e0634839160c8ead.png)
[Clickhouse column] user initialization of new library role

【C语言-数据存储】数据在内存中是怎样存储的?

Oracle learning (I)
随机推荐
Printf correlation of C
Matlab r2022a installation tutorial
Installation (detailed illustration) and use of SVN
Analysis of EN 45545 R24 oxygen index test method
php 上传大文件 超过40秒 服务器500
剑指 Offer 51. 数组中的逆序对
AS 3744.1标准中提及ISO8191测试,两者测试一样吗?
智能控制理论小题库
Android interview transcript (carefully sorted out)
BS 7176软垫家具阻燃防火测试
PHP solves Chinese display garbled code
Hibernate L2 cache
Redis6 entry-level tutorial. There are integration cases. You can directly see the integration cases. It is easy to get started
驱动壳美国测试UL 2043 符合要求有哪些?
BS 7176 fire resistance test for upholstered furniture
EN 45545-2:2020 T11烟毒性检测
For in / for of / foreach loop
EN 45545-2T10水平法烟密度检测的注意事项
TextView文本大小自动适配与TextView边距的去除
Textview text size auto fit and textview margin removal