LeetCode 237. 删除链表中的节点

题目描述

题解

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    void deleteNode(ListNode* node) {
        node->val = node->next->val;
        node->next = node->next->next;
    }
};

版权声明:本文为u013058162原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。