This commit is contained in:
krahets
2023-02-08 16:47:52 +08:00
parent 139e34bdb1
commit 7156a5f832
15 changed files with 367 additions and 208 deletions
+2 -1
View File
@@ -587,8 +587,9 @@ comments: true
/* 访问链表中索引为 index 的结点 */
function access(head, index) {
for (let i = 0; i < index; i++) {
if (!head)
if (!head) {
return null;
}
head = head.next;
}
return head;