Java Solution💪✨ | | Beats 100% 🚀🚀 | | Solution By Kanishka 🧠 🧠
IntuitionThe problem requires us to apply two operations:
If two adjacent elements are equal, double the first element and set the second element to zero.
Shift
# Intuition
The problem requires us to apply two operations:
1. If two adjacent elements are equal, double the first element and set the second element to zero.
2. Shift all non-zero elements to the left while maintaining their order, and fill the remaining positions with zeros.

To efficiently solve this, we process the array in two passes:
- **First Pass:** Apply the transformation for adjacent equal elements.
- **Second Pass:** Move all non-zero elements to the front and fill the remaining indices with zero.

# Approach
1. **First Loop:** Iterate over the array and check adjacent elements.
   - If `arr[i] == arr[i+1]`, double `arr[i]` and set `arr[i+1] = 0`.
2. **Second Loop:** Move non-zero elements to the front (`nz` index).
3. **Third Loop:** Fill the rest of the array with zeros.

# Complexity
- **Time Complexity:** $$O(n)$$  
  - The first loop runs in $$O(n)$$, and the shifting of elements runs in $$O(n)$$.
- **Space Complexity:** $$O(1)$$  
  - We modify the input array in place without using extra space.

# Code
```java
class Solution {
    public int[] applyOperations(int[] arr) {
        int nz = 0;
        int n = arr.length;

        // Step 1: Apply operations to double adjacent equal elements
        for (int i = 0; i < n - 1; i++) {
            if (arr[i] == arr[i + 1]) {
                arr[i] = arr[i]* 2;
                arr[i + 1] = 0;
            }
        }

        // Step 2: Move non-zero elements forward
        for (int i = 0; i < n; i++) {
            if (arr[i] != 0) {
                arr[nz] = arr[i];
                nz++;
            }
        }

        // Step 3: Fill remaining positions with zero
        for (int i = nz; i < n; i++) {
            arr[i] = 0;
        }

        return arr;
    }
}

['Java']