Leetcode 237 Solution

This article provides solution to leetcode question 237 (delete-node-in-a-linked-list)

https://leetcode.com/problems/delete-node-in-a-linked-list

Solution

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