LeetCode 237. 删除链表中的节点

作者: SmallRookie | 来源:发表于2019-01-04 21:34 被阅读0次

题目描述

题解

/**
 * 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;
    }
};

相关文章

网友评论

    本文标题:LeetCode 237. 删除链表中的节点

    本文链接:https://www.haomeiwen.com/subject/eyqlrqtx.html