文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
1. Description
2. Solution
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
void deleteNode(ListNode* node) {
ListNode* pre;
ListNode* current = node;
while(current->next) {
pre = current;
current = current->next;
pre->val = current->val;
}
pre->next = nullptr;
}
};