mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Update 0024.两两交换链表中的节点.md 修复没有delete dummyHead的错误
new了一个虚拟头结点,但没有delete它
This commit is contained in:
@ -63,7 +63,9 @@ public:
|
|||||||
|
|
||||||
cur = cur->next->next; // cur移动两位,准备下一轮交换
|
cur = cur->next->next; // cur移动两位,准备下一轮交换
|
||||||
}
|
}
|
||||||
return dummyHead->next;
|
ListNode* result = dummyHead->next;
|
||||||
|
delete dummyHead;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user