mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-13 14:10:38 +08:00
Update 0707.设计链表.md
This commit is contained in:
@ -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--) {
|
||||
|
Reference in New Issue
Block a user