TWO POINTER APPROACH || O(N) Time Complexity || O(1) Space Complexity || BASIC ARRAY
IntuitionApproachFirstly Declare two variable i and j where i starts from 0 and j from i+1 .
Then checking the conditions if  nums[i]==nums[j] then just multipl
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->TWO POINTER APPROACH || Basic Array Solution || Using Move Zeroes to End (Another Leetcode Question*

# Approach
<!-- Describe your approach to solving the problem. -->
Firstly Declare two variable i and j where i starts from 0 and j from i+1 .
Then checking the conditions if  nums[i]==nums[j] then just multiply the nums[i] by 2 and set the nums[j] = 0 if the condition is not true then increment the i and j.

Using Move Zeroes to End Algo
1. Check for the first index where first zero is found.
2. Insert the position of First zero'th index into a variable.
3. Start from the index+1 position and then check that value is not zero.
4. If it is then swap the zero and the value which is not zero and increment the index of j.

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
The Time complexity for this approach is O(n) because we are using a for loop.

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
Space complexity will be O(1) as we are not using any extra space in order to store the array.

UPVOTE IT IF YOU LIKEEEEEE the solution.

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