From cc302a9e8d43440605c4a61bde398784800c2b5e Mon Sep 17 00:00:00 2001 From: Aaron-Lin-74 <84072071+Aaron-Lin-74@users.noreply.github.com> Date: Fri, 4 Mar 2022 10:52:42 +1100 Subject: [PATCH] =?UTF-8?q?Update=200203.=E7=A7=BB=E9=99=A4=E9=93=BE?= =?UTF-8?q?=E8=A1=A8=E5=85=83=E7=B4=A0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable cur could be null, should add the union to the type of cur. --- problems/0203.移除链表元素.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/0203.移除链表元素.md b/problems/0203.移除链表元素.md index 4e7bdd34..c0e0be3e 100644 --- a/problems/0203.移除链表元素.md +++ b/problems/0203.移除链表元素.md @@ -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) {