Easiest Solution with Intitution (Beats 100% solutions)
Intuition
Traverse through array and apply operations as given in the question.
Count number of zeros present in array & shift digits in front.
Iterate from end
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
1. Traverse through array and apply operations as given in the question.
2. Count number of zeros present in array & shift digits in front.
3. Iterate from end to fix the positioning of zeros.


<!-- Describe your approach to solving the problem. -->

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

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

# Code
```cpp []
class Solution {
public:
    vector<int> applyOperations(vector<int>& nums) {
        int n = nums.size();

        // Applying operations
        for(int i=0;i<n-1;i++){
            if(nums[i] != nums[i+1]) continue;
            nums[i] *= 2;
            nums[i+1] = 0;
        }

        int count = 0, ptr = 0; //taking a pointer to keep a record for number index
        for(int i=0;i<n;i++){
            if(nums[i] == 0) count++;
            else { // If it is a number, put it at ptr index
                nums[ptr] = nums[i];
                ptr++;
            }
        }

        // Fixing zeros
        for(int i=0;i<count;i++){
            nums[n-i-1] = 0;
        }

        return nums;
    }
};
```
UPVOTE if it helps!
['Array', 'C++']