LeetCode 237. 删除链表中的节点

 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 class Solution {
10 public:
11     void deleteNode(ListNode* node) {
12         node->val = node->next->val;
13         node->next = node->next->next;
14     }
15 };

猜你喜欢

转载自www.cnblogs.com/FengZeng666/p/9510478.html