C++ 代码
/**
* 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) {
if(node && node->next) {
node->val = node->next->val;
auto tmp = node->next;
node->next = tmp->next;
delete tmp;
}
}
};