372.Definition of ListNode
单项列表只能把后一个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;
}
};