更新 0203.移除链表元素 排版格式修复

This commit is contained in:
jinbudaily
2023-07-18 14:28:12 +08:00
parent b51a1d89bf
commit a78116889f

View File

@ -27,14 +27,12 @@
输入head = [7,7,7,7], val = 7 输入head = [7,7,7,7], val = 7
输出:[] 输出:[]
# 算法公开课 ## 算法公开课
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[链表基础操作| LeetCode203.移除链表元素](https://www.bilibili.com/video/BV18B4y1s7R9),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 **[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[链表基础操作| LeetCode203.移除链表元素](https://www.bilibili.com/video/BV18B4y1s7R9),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
# 思路 ## 思路
为了方便大家理解,我特意录制了视频:[链表基础操作| LeetCode203.移除链表元素](https://www.bilibili.com/video/BV18B4y1s7R9),结合视频在看本题解,事半功倍。
这里以链表 1 4 2 4 来举例移除元素4。 这里以链表 1 4 2 4 来举例移除元素4。
@ -91,7 +89,7 @@
最后呢在题目中return 头结点的时候,别忘了 `return dummyNode->next;` 这才是新的头结点 最后呢在题目中return 头结点的时候,别忘了 `return dummyNode->next;` 这才是新的头结点
# C++代码 ### C++代码
**直接使用原来的链表来进行移除节点操作:** **直接使用原来的链表来进行移除节点操作:**
@ -159,7 +157,7 @@ public:
## 其他语言版本 ## 其他语言版本
C: ### C:
用原来的链表操作: 用原来的链表操作:
```c ```c
@ -227,7 +225,7 @@ struct ListNode* removeElements(struct ListNode* head, int val){
} }
``` ```
Java ### Java
```java ```java
/** /**
@ -308,7 +306,7 @@ public ListNode removeElements(ListNode head, int val) {
} }
``` ```
Python ### Python
```python ```python
版本一虚拟头节点法 版本一虚拟头节点法
@ -334,7 +332,7 @@ class Solution:
``` ```
Go ### Go
```go ```go
/** /**
@ -359,7 +357,7 @@ func removeElements(head *ListNode, val int) *ListNode {
} }
``` ```
javaScript: ### JavaScript:
```js ```js
/** /**
@ -381,7 +379,7 @@ var removeElements = function(head, val) {
}; };
``` ```
TypeScript: ### TypeScript:
版本一(在原链表上直接删除): 版本一(在原链表上直接删除):
@ -437,7 +435,7 @@ function removeElements(head: ListNode | null, val: number): ListNode | null {
}; };
``` ```
Swift ### Swift
```swift ```swift
/** /**
@ -465,7 +463,7 @@ func removeElements(_ head: ListNode?, _ val: Int) -> ListNode? {
} }
``` ```
PHP: ### PHP:
```php ```php
/** /**
@ -493,7 +491,7 @@ func removeElements(head *ListNode, val int) *ListNode {
} }
``` ```
RUST: ### Rust:
```rust ```rust
// Definition for singly-linked list. // Definition for singly-linked list.
@ -531,7 +529,7 @@ impl Solution {
} }
``` ```
Scala: ### Scala:
```scala ```scala
/** /**
@ -564,7 +562,7 @@ object Solution {
} }
``` ```
Kotlin: ### Kotlin:
```kotlin ```kotlin
/** /**
@ -600,7 +598,8 @@ class Solution {
} }
``` ```
C# ### C#
```CSharp ```CSharp
/** /**
* Definition for singly-linked list. * Definition for singly-linked list.