Skip to content

Commit

Permalink
Merge pull request youngyangyang04#951 from adjfks/master
Browse files Browse the repository at this point in the history
修改了707设计链表javascript版本题解的删除节点操作,增加了对尾节点的处理
  • Loading branch information
youngyangyang04 authored Dec 20, 2021
2 parents 19bb9df + 99ff6dd commit cd4f1fb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions problems/0707.设计链表.md
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,10 @@ MyLinkedList.prototype.deleteAtIndex = function(index) {
if(index < 0 || index >= this._size) return;
if(index === 0) {
this._head = this._head.next;
// 如果删除的这个节点同时是尾节点,要处理尾节点
if(index === this._size - 1){
this._tail = this._head
}
this._size--;
return;
}
Expand Down

0 comments on commit cd4f1fb

Please sign in to comment.