Java || Beats 80% || Easy Approach
Intuition\n- Iterate singly-linked list and calculate sum between zero nodes\n- Add them into seperate linked list.\n\n# Approach\n- Create new linked-list ans\
# Intuition\n- Iterate singly-linked list and calculate sum between zero nodes\n- Add them into seperate linked list.\n\n# Approach\n- Create new linked-list **ans**\n- Set curr to head of given linked list\n- Initialize sum variable with value 0.\n- ***If curr.value == 0*** then add sum into ans linked list & sum = 0\n- ***Else*** sum = sum + curr.value\n- Return **ans** linked list.  \n\n# Complexity\n- Time complexity:\n$$O(n)$$ \n\n- Space complexity:\n$$O(1)$$ \n\n# Code\n```\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 ans = new ListNode(0);\n        ListNode cur = ans;\n        ListNode curr = head;\n        int sum = 0;\n        while(curr != null){\n            if(curr.val == 0){\n                if(sum != 0){\n                    cur.next = new ListNode(sum);\n                    cur = cur.next;\n                    sum = 0;\n                }\n            }\n            else{\n                sum += curr.val;\n            }\n            curr = curr.next;\n        }\n        return ans.next;\n    }\n}\n```
['Java']