Solution using C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\n *     ListNode(int x) : val(x), next(nullptr) {}\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) {\n        while (head->val == 0)\n        {\n            head = head->next;\n        }\n        ListNode* cur = head;\n        while (cur)\n        {\n            if (cur->next)\n            {\n                if (cur->next->val != 0)\n                {\n                    cur->val += cur->next->val;\n                    cur->next = cur->next->next;\n                    continue;\n                }\n                else cur->next = cur->next->next;\n            }\n            cur = cur->next;\n        }\n        return head;\n    }\n};\n```
['C++']