Skip to content

Latest commit

 

History

History
11 lines (10 loc) · 260 Bytes

File metadata and controls

11 lines (10 loc) · 260 Bytes
  • 因为删除的是非末尾节点,将下一节点的值拷贝到当前节点,再跳过下一节点即可
class Solution {
 public:
  void deleteNode(ListNode* node) {
    node->val = node->next->val;
    node->next = node->next->next;
  }
};