Skip to content

Instantly share code, notes, and snippets.

@qiaoxu123
Last active March 3, 2019 23:51
Show Gist options
  • Save qiaoxu123/d0da8c19ff11c7652276838990732484 to your computer and use it in GitHub Desktop.
Save qiaoxu123/d0da8c19ff11c7652276838990732484 to your computer and use it in GitHub Desktop.
> 很简单的链表节点删除题目,在这因为给出的是要被删除的节点,因此需要将它的值替换,将它的下一个节点进行删除,从而实现链表节点的-1操作
//Runtime: 12 ms, faster than 100.00%
//Memory Usage: 9.2 MB, less than 42.80%
class Solution {
public:
void deleteNode(ListNode* node) {
node->val = node->next->val;
node->next = node->next->next;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment