Skip to content

Commit

Permalink
fix 链表的越界判断
Browse files Browse the repository at this point in the history
  • Loading branch information
biaochenxuying committed Aug 1, 2019
1 parent 299ae5a commit 44af955
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data-structure-and-algorithms/1. singly-linked-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

// 向链表特定位置插入一个新节点
this.insert = function(position, element) {
if (position < 0 && position > length) {
if (position < 0 || position > length) {
// 越界
return false;
} else {
Expand Down
2 changes: 1 addition & 1 deletion data-structure-and-algorithms/2. doubly-linked-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

// 向链表特定位置插入一个新的项
this.insert = function(position, element) {
if (position < 0 && position > length) {
if (position < 0 || position > length) {
// 越界
return false;
} else {
Expand Down

0 comments on commit 44af955

Please sign in to comment.