An interview problem I encountered years ago.. 1AC
class Solution { public: void deleteNode(ListNode* node) { if(!node) return; ListNode *p1 = node; ListNode *p2 = node->next; while(p1 && p2) { p1->val = p2->val; if(!p2->next) { p1->next = nullptr; return; } p1 = p2; p2 = p2->next; } } };