Skip to content

Commit 6efb90c

Browse files
Merge pull request youngyangyang04#1601 from starry0819/master
更新 0707.设计链表.md Java示例代码部分功能
2 parents 230e9d9 + 51b4a8a commit 6efb90c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

problems/0707.设计链表.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,12 @@ class MyLinkedList {
353353
return;
354354
}
355355
size--;
356+
if (index == 0) {
357+
head = head.next;
358+
return;
359+
}
356360
ListNode pred = head;
357-
for (int i = 0; i < index; i++) {
361+
for (int i = 0; i < index - 1; i++) {
358362
pred = pred.next;
359363
}
360364
pred.next = pred.next.next;

0 commit comments

Comments
 (0)