Leetcode 237 Solution
This article provides solution to leetcode question 237 (delete-node-in-a-linked-list)
Access this page by simply typing in "lcs 237" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
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;
}
};