Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdea9b51

Browse files
committed
203-remove-linked-list-elements.md Separated Chinese and English solutions.
1 parentb33e440 commitdea9b51

File tree

2 files changed

+26
-80
lines changed

2 files changed

+26
-80
lines changed

‎en/1-1000/203-remove-linked-list-elements.md

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#203. Remove Linked List Elements - Best Practices of LeetCode Solutions
2-
LeetCode link:[203. Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements),
3-
[203. 移除链表元素](https://leetcode.cn/problems/remove-linked-list-elements)
2+
LeetCode link:[203. Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements), difficulty:**Easy**.
43

5-
[中文题解](#中文题解)
6-
7-
##LeetCode problem description
4+
##LeetCode description of "203. Remove Linked List Elements"
85
Given the`head` of a linked list and an integer`val`, remove all the nodes of the linked list that has`Node.val == val`, and return_the new head_.
96

107
###[Example 1]
@@ -30,8 +27,6 @@ Given the `head` of a linked list and an integer `val`, remove all the nodes of
3027
-`0 <= val <= 50`
3128

3229
##Intuition
33-
[中文题解](#中文题解)
34-
3530
Assume that the node to be deleted in the linked list is`d`, and the previous node of`d` is`p`, so`p.next` is`d`.
3631

3732
To delete`d`, just set`p.next = p.next.next`.
@@ -272,24 +267,3 @@ end
272267
```
273268
// Welcome to create a PR to complete the code of this language, thanks!
274269
```
275-
276-
##问题描述
277-
给你一个链表的头节点`head` 和一个整数`val` ,请你删除链表中所有满足`Node.val == val` 的节点,并返回**新的头节点**
278-
279-
###[Example 1]
280-
![](../../images/examples/203_1.jpg)
281-
282-
**Input**:`head = [1,2,6,3,4,5,6], val = 6`
283-
284-
**Output**:`[1,2,3,4,5]`
285-
286-
##中文题解
287-
假设链表中待删除的节点是`d``d`的前一个节点是`p`,所以`p.next`就是`d`。 删除`d`,只需要把`p.next = p.next.next`
288-
289-
因为用到了`p.next.next`,所以循环条件应为`while (p.next != null)`,而不是`while (p != null)`
290-
291-
`head`节点前面没有节点,这就意味着需要对`head`节点进行特殊处理。
292-
293-
是否有方法能够让`head`节点的不再特殊呢?这样就不需要特殊处理`head`了。
294-
295-
办法是引入`dummy`节点,`dummy.next = head`

‎zh/1-1000/203-remove-linked-list-elements.md

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,45 @@
1-
#203. Remove Linked List Elements - Best Practices of LeetCode Solutions
2-
LeetCode link:[203. Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements),
3-
[203. 移除链表元素](https://leetcode.cn/problems/remove-linked-list-elements)
1+
#203. 移除链表元素 - 力扣题解最佳实践
2+
力扣链接:[203. 移除链表元素](https://leetcode.cn/problems/remove-linked-list-elements), 难度:**简单**
43

5-
[中文题解](#中文题解)
6-
7-
##LeetCode problem description
8-
Given the`head` of a linked list and an integer`val`, remove all the nodes of the linked list that has`Node.val == val`, and return_the new head_.
4+
##力扣“203. 移除链表元素”问题描述
5+
给你一个链表的头节点`head` 和一个整数`val` ,请你删除链表中所有满足`Node.val == val` 的节点,并返回**新的头节点**
96

10-
###[Example 1]
7+
###[示例 1]
118
![](../../images/examples/203_1.jpg)
129

13-
**Input**:`head = [1,2,6,3,4,5,6], val = 6`
10+
**输入**:`head = [1,2,6,3,4,5,6], val = 6`
1411

15-
**Output**:`[1,2,3,4,5]`
12+
**输出**:`[1,2,3,4,5]`
1613

17-
###[Example 2]
18-
**Input**:`head = [], val = 1`
14+
###[示例 2]
15+
**输入**:`head = [], val = 1`
1916

20-
**Output**:`[]`
17+
**输出**:`[]`
2118

22-
###[Example 3]
23-
**Input**:`head = [7,7,7,7], val = 7`
19+
###[示例 3]
20+
**输入**:`head = [7,7,7,7], val = 7`
2421

25-
**Output**:`[]`
22+
**输出**:`[]`
2623

27-
###[Constraints]
28-
-The number of nodes in the list is in the range`[0, 10000]`.
24+
###[约束]
25+
-列表中的节点数目在范围`[0, 10000]`
2926
-`1 <= Node.val <= 50`
3027
-`0 <= val <= 50`
3128

32-
##Intuition
33-
[中文题解](#中文题解)
34-
35-
Assume that the node to be deleted in the linked list is`d`, and the previous node of`d` is`p`, so`p.next` is`d`.
36-
37-
To delete`d`, just set`p.next = p.next.next`.
29+
##思路
30+
假设链表中待删除的节点是`d``d`的前一个节点是`p`,所以`p.next`就是`d`。 删除`d`,只需要把`p.next = p.next.next`
3831

39-
Because`p.next.next` is used, the loop condition should be`while (p.next != null)` instead of`while (p != null)`.
32+
因为用到了`p.next.next`,所以循环条件应为`while (p.next != null)`,而不是`while (p != null)`
4033

41-
But there is no node before the`head` node, which means that the`head` node needs to be treated specially.
34+
`head`节点前面没有节点,这就意味着需要对`head`节点进行特殊处理。
4235

43-
Is there a way to make the`head` node no longer special? In this way, there is no need to treat the`head` specially.
36+
是否有方法能够让`head`节点的不再特殊呢?这样就不需要特殊处理`head`了。
4437

45-
The way is to introduce a`dummy` node,`dummy.next = head`.
38+
办法是引入`dummy`节点,`dummy.next = head`
4639

47-
##Complexity
48-
*Time:`O(n)`.
49-
*Space:`O(1)`.
40+
##复杂度
41+
*时间:`O(N)`
42+
*空间:`O(1)`
5043

5144
##Java
5245
```java
@@ -272,24 +265,3 @@ end
272265
```
273266
// Welcome to create a PR to complete the code of this language, thanks!
274267
```
275-
276-
##问题描述
277-
给你一个链表的头节点`head` 和一个整数`val` ,请你删除链表中所有满足`Node.val == val` 的节点,并返回**新的头节点**
278-
279-
###[Example 1]
280-
![](../../images/examples/203_1.jpg)
281-
282-
**Input**:`head = [1,2,6,3,4,5,6], val = 6`
283-
284-
**Output**:`[1,2,3,4,5]`
285-
286-
##中文题解
287-
假设链表中待删除的节点是`d``d`的前一个节点是`p`,所以`p.next`就是`d`。 删除`d`,只需要把`p.next = p.next.next`
288-
289-
因为用到了`p.next.next`,所以循环条件应为`while (p.next != null)`,而不是`while (p != null)`
290-
291-
`head`节点前面没有节点,这就意味着需要对`head`节点进行特殊处理。
292-
293-
是否有方法能够让`head`节点的不再特殊呢?这样就不需要特殊处理`head`了。
294-
295-
办法是引入`dummy`节点,`dummy.next = head`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp