👩‍💻Easy 🔥 Just read & code💻
Please Upvote only if you get something from my Solution! 💡🙌Don't give up! Keep practising! 😊🔥📚First just store array length in variable n.Then create new array
# Please Upvote only if you get something from my Solution! 💡🙌
# Don't give up! Keep practising! 😊🔥📚
------------------------------------------------------
First just store array length in variable n.

    int n=nums.length;  
Then create new array ans[] of size n.

    int ans[]=new int[n];
Then use for loop & just do as mntion in the question.
if nums[i]==nums[i+1] then multiply nums[i] by 2 and nums[i+1]=0.

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

Now we just need to shift all zeros to end of the array.
So,we use for each loop and check inside it.
If x is not zero, then add it to our ans array.

    int i=0;
    for(int x:nums){
        if(x!=0){
            ans[i]=x;
            i++;
        } 
    }

Then finally, return the array.

            return ans;

# Please Upvote only if you get something from my Solution! 💡🙌
# Don't give up! Keep practising! 😊🔥📚
# Code
```java []
class Solution {
    public int[] applyOperations(int[] nums) {
        int n=nums.length;
        int ans[]=new int[n];
        for(int i=0;i<n-1;i++){
            if(nums[i]==nums[i+1]){
                nums[i]*=2;
                nums[i+1]=0;
            }
        }

        int i=0;
        for(int x:nums){
            if(x!=0){
                ans[i]=x;
                i++;
            } 
        }

        return ans;
    }
}
```
['Array', 'Java']