标签:nbsp 删除 void col public oid linked lis tno
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 8 */ 9 //用node节点的下一个节点覆盖该节点 10 //然后node->next = node->next->next; 11 //如果node为最后一个节点,直接node指向NULL 12 class Solution 13 { 14 public: 15 void deleteNode(ListNode* node) 16 { 17 if(node->next == NULL) 18 { 19 node == NULL; 20 return; 21 } 22 node->val = node->next->val; 23 node->next = node->next->next; 24 } 25 };
标签:nbsp 删除 void col public oid linked lis tno
原文地址:https://www.cnblogs.com/yuhong1103/p/12543069.html