Merge pull request #1137 from Aaron-Lin-74/patch-1

Update 0203.移除链表元素.md
This commit is contained in:
程序员Carl
2022-03-23 09:27:05 +08:00
committed by GitHub

View File

@ -324,7 +324,7 @@ function removeElements(head: ListNode | null, val: number): ListNode | null {
head = head.next;
}
if (head === null) return head;
let pre: ListNode = head, cur: ListNode = head.next;
let pre: ListNode = head, cur: ListNode | null = head.next;
// 删除非头部节点
while (cur) {
if (cur.val === val) {