Java ✅🤯 - Best Solution
IntuitionApproach
Iterate through the array, doubling adjacent equal numbers and setting the next one to zero.
Move all non-zero elements to the front while mai
# Intuition
<!-- Describe your first thoughts on how to solve this problem. --> Modify the array by doubling adjacent equal elements and setting the next element to zero, then shift non-zero elements forward.

# Approach
<!-- Describe your approach to solving the problem. -->
1. Iterate through the array, doubling adjacent equal numbers and setting the next one to zero.
2. Move all non-zero elements to the front while maintaining order.

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

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

# Code
```java []
class Solution {
    public int[] applyOperations(int[] nums) {
        for(int i=0; i<nums.length-1; i++){
            if(nums[i]==nums[i+1]){
                nums[i] *= 2;
                nums[i+1]=0;
            }
        } 
        moveZeroes(nums);
        return nums;
    }
    public void moveZeroes(int[] nums) {
        int index=0;
        for(int num:nums){
            if(num!=0){
                nums[index++]=num;
            }
        }
        while(index<nums.length){
            nums[index++]=0;

        }
    }
}
```
['Java']