Skip to content

Instantly share code, notes, and snippets.

@kanrourou
Created December 25, 2018 22:56
Show Gist options
  • Save kanrourou/9a6b404c8202ae8de667fb301b26682d to your computer and use it in GitHub Desktop.
Save kanrourou/9a6b404c8202ae8de667fb301b26682d to your computer and use it in GitHub Desktop.
/**
* 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;
auto tmp = node->next;
node->next = tmp->next;
tmp->next = nullptr;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment