JavaScript Solution || Using Array Iteration || Beats 100% Users ||
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

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

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

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

# Code
```javascript []
/**
 * @param {number[]} nums
 * @return {number[]}
 */
var applyOperations = function(nums) {
    const arr=[]
    var l=nums.length
    for(let i=0;i<l-1;i++){
        if(nums[i]==nums[i+1]){nums[i]*=2;nums[i+1]=0;i++;}
    }
    var counter=0;
    nums.forEach((ele,index)=>{
        if(ele===0) {counter++;}
        else{
        arr.push(ele)
        }
    })
    while(counter){
        arr.push(0)
        counter--;
    }
    return arr
    
};
```
['JavaScript']