Easiest and 99% faster soln both in Memory and Space
\n# Approach\n Describe your approach to solving the problem. \nIn this solution, what we are doing is we are just adding the value of nodes other than 0 to nod
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIn this solution, what we are doing is we are just adding the value of nodes other than 0 to node having value 0 and we are joining only nodes having value 0\nAnd at the end we are just skipping the node having value 0\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) {\n        ListNode* prev = head, *curr= prev->next;\n\n        while(curr){\n            \n            if(prev->val==0){       //adding value of other nodes to \n                while(curr->val!=0){    //node with value 0\n                    prev->val +=curr->val;\n                    curr = curr->next;\n                }\n                if(curr->next == NULL){ // for handling last node with 0\n                    prev->next = NULL;\n                    break;\n                }\n                if(curr->val==0){   //joining nodes with value 0\n                    prev->next=curr;\n                    prev=curr;\n                }\n            }\n            curr=curr->next;\n        }\n        return head;\n    }\n};\n```
['Linked List', 'C', 'C++']