/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
/*class Solution {
public:
//以为题目出错了,把node当成头结点了,以为没给要删除的节点的值,于是自己改了接口hhhhhhhhhhhh
void deleteNode(ListNode* node, int num) {
ListNode *first = node, *second = node->next;
while(second->val != num){
first = second;
second = second->next;
}
first->next = second->next;
}
};*/
class Solution {
public:
void deleteNode(ListNode* node) {
node->val = node->next->val;
node->next = node->next->next;
}
};