#2181 || Python3, O(N) || Easy to Understand || Runtime: 4723 ms (20.00% faster) / Memory: 72.9 MB
How can you use two pointers to modify the original list into the new list?\n~\nHave a pointer traverse the entire linked list, while another pointer looks at a
How can you use two pointers to modify the original list into the new list?\n~\nHave a pointer traverse the entire linked list, while another pointer looks at a node that is currently being modified.\n~\nKeep on summing the values of the nodes between the traversal pointer and the modifying pointer until the former comes across a \u20180\u2019. In that case, the modifying pointer is incremented to modify the next node.\n~\nDo not forget to have the next pointer of the final node of the modified list point to null.\n\n```\n    def mergeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]:\n        \n        head = head.next\n        node = head\n        while node:\n            while node.next.val != 0:\n                node.val += node.next.val\n                node.next = node.next.next\n            \n            node.next = node.next.next\n            node = node.next\n\n        return head\n    \n# Time: O(N)\n# Space: O(1)\n```\n\n![image](https://assets.leetcode.com/users/images/9f2a5768-b77e-44c1-afa4-bbfbb876a064_1645381822.4103515.png)\n\n--------\n--------\n**Find this solution and many others on my Github:** https://github.com/dimon41k2010/LeetCodeTasks/blob/main/2181-merge-nodes-in-between-zeros/2181-merge-nodes-in-between-zeros.py\n\n**Please upvote if it makes sence and helpful to you. Let\'s stay motivated! Peace.**
['Linked List', 'Python', 'Python3']