Optimized In-Place Array Transformation | Beats 💯% | Pseudo Code
Intuition~ The problem requires us to perform two operations on the given array nums:
Merge adjacent equal elements: If nums[i] == nums[i+1], we double nums[i]
# Intuition
~ The problem requires us to perform two operations on the given array nums:
- Merge adjacent equal elements: If nums[i] == nums[i+1], we double nums[i] and set nums[i+1] to 0.
- Shift all non-zero elements to the left: Move all 0s to the end while maintaining the relative order of non-zero elements.

# Approach
- Step 1: Merge Adjacent Equal Elements
    - Traverse the array from i = 0 to n-2.
    - If nums[i] == nums[i+1], set nums[i] = nums[i] * 2 and nums[i+1] = 0.
    - This ensures that every adjacent pair is checked only once, merging them if they are equal.
- Step 2: Shift Non-Zero Elements to the Left
    - Traverse the array again while maintaining a pointer zero that tracks the position where the next non-zero element should be placed.
    - If nums[i] is non-zero, swap nums[i] with nums[zero] and increment zero.
    - This effectively moves all non-zero elements to the front while pushing 0s to the end.

# Complexity
- Time complexity:
    - ***O(N)***

- Space complexity:
    - ***O(1)***

# ~ If this Solution was helpfull make sure to upvote!!✅✅🔥🔥

# 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] = nums[i] * 2;
                nums[i + 1] = 0;
            }
        }

        int zero = 0;
        for(int i = 0; i < n ; i++)
        {
            if(nums[i] != 0)
            {
                swap(nums[i] , nums[zero]);
                zero++;
            }
        }
        return nums;
    }
};
```

# ~ If this Solution was helpfull make sure to upvote!!✅✅🔥🔥
['Array', 'Two Pointers', 'Simulation', 'C++']