mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Merge pull request #1137 from Aaron-Lin-74/patch-1
Update 0203.移除链表元素.md
This commit is contained in:
@ -324,7 +324,7 @@ function removeElements(head: ListNode | null, val: number): ListNode | null {
|
|||||||
head = head.next;
|
head = head.next;
|
||||||
}
|
}
|
||||||
if (head === null) return head;
|
if (head === null) return head;
|
||||||
let pre: ListNode = head, cur: ListNode = head.next;
|
let pre: ListNode = head, cur: ListNode | null = head.next;
|
||||||
// 删除非头部节点
|
// 删除非头部节点
|
||||||
while (cur) {
|
while (cur) {
|
||||||
if (cur.val === val) {
|
if (cur.val === val) {
|
||||||
|
Reference in New Issue
Block a user