Java
Pls upvote if u like it\n\n\npublic ListNode mergeNodes(ListNode head) {\n    ListNode cur;\n    ListNode res = new ListNode(-1);\n    cur = res;\n    int sum =
Pls upvote if u like it\n\n```\npublic ListNode mergeNodes(ListNode head) {\n    ListNode cur;\n    ListNode res = new ListNode(-1);\n    cur = res;\n    int sum = 0;\n\n    while (head != null) {\n        if (head.val != 0) {\n            sum += head.val;\n        } else {\n            cur.next = new ListNode(sum);\n            cur = cur.next;\n            sum = 0;\n        }\n        head = head.next;\n    }\n    return res.next.next;\n}\n\n```
['Java']