✅Recursive and Iterative solution || C++ || Easy
Recursive solution\n\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) {\n        if(!head || !head->next) return head;\n        ListNode *sl
**Recursive solution**\n```\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) {\n        if(!head || !head->next) return head;\n        ListNode *slow=head;\n        ListNode *fast=head;\n        do\n        {\n            fast=fast->next;\n        }\n        while(fast->val!=0);\n            \n        int sum =0;\n        while(slow!=fast)\n        {\n            sum+=slow->val;\n            slow=slow->next;\n        }\n        ListNode *newll = new ListNode(sum);\n        newll->next = mergeNodes(fast->next);\n        return newll;\n    \n    }\n};\n```\n\n**Iterative solution**\n```\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) {\n        head=head->next;\n        ListNode*start=head;\n        while(start)\n        {\n            ListNode*end=start;\n            int sum=0;\n            while(end->val!=0){ sum+=end->val; end=end->next;}\n            start->val=sum;\n            start->next=end->next;\n            start=start->next;\n        }\n        return head;\n    }\n};\n```\n***Do upvote if it helped! Feel free to comment :)***
['Linked List', 'Recursion', 'C', 'Iterator', 'C++']