Beats 94.12% users | | easy approach check it ✅🧑‍💻
Bold# Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach Two pointer\n Describe your approach to solving the problem. \n\n# C
**Bold**# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach Two pointer\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: O ( 1 )\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * function ListNode(val, next) {\n *     this.val = (val===undefined ? 0 : val)\n *     this.next = (next===undefined ? null : next)\n * }\n */\n/**\n * @param {ListNode} head\n * @return {ListNode}\n */\nvar mergeNodes = function (head) {\n\n  let modify = head.next\n  let nextSum = modify \n\n  while(nextSum !== null ){\n    let sum = 0 ;\n    while(nextSum.val !== 0){\n        sum += nextSum.val\n        nextSum = nextSum.next\n    }\n    modify.val = sum\n    nextSum = nextSum.next\n\n    modify.next = nextSum\n    modify = modify.next\n  }  \n\n  return head.next\n};\n```
['JavaScript']