mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
更新 0707.设计链表.md Java示例代码部分功能
0707.设计链表.md 中 Java示例代码中,单链表的deleteAtIndex方法进行了修改。
This commit is contained in:
@ -353,8 +353,12 @@ class MyLinkedList {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size--;
|
size--;
|
||||||
|
if (index == 0) {
|
||||||
|
head = head.next;
|
||||||
|
return;
|
||||||
|
}
|
||||||
ListNode pred = head;
|
ListNode pred = head;
|
||||||
for (int i = 0; i < index; i++) {
|
for (int i = 0; i < index - 1; i++) {
|
||||||
pred = pred.next;
|
pred = pred.next;
|
||||||
}
|
}
|
||||||
pred.next = pred.next.next;
|
pred.next = pred.next.next;
|
||||||
|
Reference in New Issue
Block a user