Beginner friendly java solution
\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val)
```\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val) { this.val = val; }\n *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n    public ListNode mergeNodes(ListNode head) {\n        ListNode curr, root = new ListNode();\n        curr = root;\n        int sum = 0;\n        while(head != null){\n            if(head.val == 0 && sum != 0){\n                curr.next = new ListNode(sum);\n                curr = curr.next;\n                sum = 0;   \n            }\n            sum += head.val;\n            head = head.next;\n        }\n        return root.next;\n    }\n}\n```
['Java']