Iterative Method Using Dummy Node | C++
This is the approach I came up with:\n\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) {\n        ListNode* dummy = new ListNode(0);\n     
This is the approach I came up with:\n```\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) {\n        ListNode* dummy = new ListNode(0);\n        ListNode* ptr = dummy;\n        ListNode* temp = head;\n        while(temp->next!=NULL){\n            int sum=0;\n            while(temp->next!=NULL && temp->next->val!=0){\n                sum+=temp->next->val;\n                temp=temp->next;\n            }\n            ListNode* x = new ListNode(sum);\n            ptr->next=x;\n            ptr=ptr->next;\n            temp=temp->next;\n        }\n        return dummy->next;\n    }\n};\n```
['Linked List', 'C', 'Iterator', 'C++']