Easiest C++ approach using Vectors || Beats 97% Time Complexity
Intuition\nPostive Mindset\n\n# Approach\nUsing Vectors\n\n# Complexity\n- Time complexity:\nO(mlog(n))\n\n- Space complexity:\nO(n+m)\n\n# Code\n\n/**\n * Defi
# Intuition\nPostive Mindset\n\n# Approach\nUsing Vectors\n\n# Complexity\n- Time complexity:\nO(mlog(n))\n\n- Space complexity:\nO(n+m)\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\n *     ListNode(int x) : val(x), next(nullptr) {}\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n    ListNode* mergeNodes(ListNode* head) {\n        vector<int> a,ans;\n        ListNode* temp = head;\n        while(temp!=NULL){\n            a.push_back(temp->val);\n            temp = temp->next;\n        }\n        int n = a.size();\n        for(int i=0;i<n;i++){\n            int count = 0;\n            for(int j=i+1;j<n;j++){\n                if(a[i]==0 && a[j]!=0){\n                    count = count + a[j];\n                }\n                else if(a[j]==0){\n                    ans.push_back(count);\n                    i=j-1;\n                    break;\n                    \n                }\n            }\n        }\n        n = ans.size();\n        temp = head;\n        for(int i=0;i<n;i++){\n            temp->val = ans[i];\n            if(i==n-1){\n                temp->next = NULL;\n                break;\n            }\n            temp=temp->next;\n        }\n        return head;\n    }\n};\n```
['C++']