Short and sweet solution in Leetcode history
\n\n# Code\n\nclass Solution {\npublic:\n    vector<int> applyOperations(vector<int>& nums) {\n        int n=nums.size();\n        for(int i=0;i<n-1;i++){\n    
\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> applyOperations(vector<int>& nums) {\n        int n=nums.size();\n        for(int i=0;i<n-1;i++){\n            if(nums[i]==nums[i+1]){\n                nums[i]=nums[i]*2;\n                nums[i+1]=0;\n            }\n        }\n        int nc=0;\n        for(int i=0;i<n;i++){\n            if(nums[i]!=0){\n                swap(nums[nc],nums[i]);\n                nc++;\n            }\n        }\n        return nums;\n    }\n};\n```
['Array', 'C++']