Merge pull request #2589 from WuTao1103/master

java单链表版本中,因为有虚拟头节点,所以不用对Index=0的情况进行特殊处理
This commit is contained in:
程序员Carl
2024-07-09 11:26:18 +08:00
committed by GitHub

View File

@ -380,10 +380,7 @@ class MyLinkedList {
return;
}
size--;
if (index == 0) {
head = head.next;
return;
}
//因为有虚拟头节点所以不用对Index=0的情况进行特殊处理
ListNode pred = head;
for (int i = 0; i < index ; i++) {
pred = pred.next;