One-Pass
C++\ncpp\nListNode* mergeNodes(ListNode* head) {\n    for (auto *p_z = head, *p = head->next; p != nullptr; p = p->next) {\n        if (p->val != 0)\n          
**C++**\n```cpp\nListNode* mergeNodes(ListNode* head) {\n    for (auto *p_z = head, *p = head->next; p != nullptr; p = p->next) {\n        if (p->val != 0)\n            p_z->val += p->val;\n        else {\n            p_z->next = p->next != nullptr ? p : nullptr;\n            p_z = p;\n        }\n    }\n    return head;\n}\n```
[]