simple and easy 2 C++ solution 😍❤️‍🔥
if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code1\n\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) \n    {\n        int sum 
# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code1\n```\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) \n    {\n        int sum = 0;\n        head = head->next;\n        ListNode* ans = new ListNode(sum);\n        ListNode* tail = ans;\n        while(head)\n        {\n            sum += head->val;\n            if(not head->val)\n            {\n                tail->next = new ListNode(sum);\n                tail = tail->next;\n                sum = 0;\n            }\n            head = head->next;\n        }\n        return ans->next;\n    }\n};\n```\n\n# Code2\n```\nclass Solution \n{\npublic:\n    void insert_(ListNode*&newhead,ListNode*&newtail,int val)\n    {\n        ListNode*newnode=new ListNode(val);\n        if(newhead==NULL)\n        {\n            newhead=newnode;\n            newtail=newnode;\n            return;\n        }\n        newtail->next=newnode;\n        newtail=newnode;\n    }\n    ListNode* mergeNodes(ListNode* head) \n    {\n        ListNode*newhead=NULL;\n        ListNode*newtail=NULL;\n        int sum=0;\n        ListNode*tmp=head->next;\n        while(tmp!=NULL)\n        {\n            if(tmp->val==0)\n            {\n                insert_(newhead,newtail,sum);\n                sum=0;\n            }\n            sum=sum+tmp->val;\n            tmp=tmp->next;\n        }\n        return newhead;\n    }\n};\n```
['Linked List', 'Simulation', 'C++']