CPP || 100% beats || easy to understand
Complexity
Time complexity: O(N)

Space complexity: O(N)
Code
# 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)$$ -->
![upvote.jpg](https://assets.leetcode.com/users/images/f8f7e8ba-1ce7-453d-8728-5002617cdabf_1740800031.834896.jpeg)

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