100% Beat Simple Solution
Complexity
Time complexity: O(N)

Space complexity: O(N)
Code
![image.png](https://assets.leetcode.com/users/images/33649b56-77d7-4b52-a752-f06e00ffd589_1740801448.0410573.png)


# Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

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