Simple CPP solution beats 100%
Code


# Code
```cpp []
class Solution {
public:
    vector<int> applyOperations(vector<int>& nums) {
        int n = nums.size();
        vector<int> ans(n,0);
        int idx=0;
        for(int i=0;i<n;i++){
             if(i<n-1 && nums[i] == nums[i+1] && nums[i]!=0){
                ans[idx++]=nums[i]*2;
                i++;
            }
            else if(nums[i]!=0){
                ans[idx++]=nums[i];
            }
        }
        return ans;
    }
};
```
['C++']