O(1) Space || Single Pass || BEATS 100% || Single Loop
Fastest Code with Single LoopComplexity
Time complexity:
O(N)
Space complexity:
O(1)
Code
**Fastest Code with Single Loop**
# Complexity
- Time complexity:
O(N)
- Space complexity:
O(1)

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