Last active
March 3, 2019 23:51
-
-
Save qiaoxu123/d0da8c19ff11c7652276838990732484 to your computer and use it in GitHub Desktop.
> 很简单的链表节点删除题目,在这因为给出的是要被删除的节点,因此需要将它的值替换,将它的下一个节点进行删除,从而实现链表节点的-1操作
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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