![372.Definition of ListNode 372.Definition of ListNode](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
单项列表只能把后一个node中的所有数据copy到当前node再delete后一node。
/**
* Definition of ListNode
* class ListNode {
* public:
* int val;
* ListNode *next;
* ListNode(int val) {
* this->val = val;
* this->next = NULL;
* }
* }
*/
class Solution {
public:
/*
* @param node: the node in the list should be deletedt
* @return: nothing
*/
void deleteNode(ListNode * node) {
// write your code here
node->val = node->next->val;
ListNode *tmp = node->next;
node ->next = node->next->next;
delete tmp;
}
};