mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
java单链表版本中,因为有虚拟头节点,所以不用对Index=0的情况进行特殊处理
This commit is contained in:
@ -365,10 +365,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;
|
||||
|
Reference in New Issue
Block a user