Update 0707.设计链表.md

This commit is contained in:
程序员Carl
2022-07-07 09:00:14 +08:00
committed by GitHub
parent d0814a723c
commit 0c6b1db35c

View File

@ -106,12 +106,9 @@ public:
// 如果index大于链表的长度则返回空
// 如果index小于0则置为0作为链表的新头节点。
void addAtIndex(int index, int val) {
if (index > _size) {
if (index > _size || index < 0) {
return;
}
else if (index < 0) {
index = 0;
}
LinkedNode* newNode = new LinkedNode(val);
LinkedNode* cur = _dummyHead;
while(index--) {