Simple solution for beginners
IntuitionThe problem involves modifying an array based on specific rules:
If two adjacent numbers are the same, double the first one and set the second to zero.
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem involves modifying an array based on specific rules:

1. If two adjacent numbers are the same, double the first one and set the second to zero.
2. After processing the array, shift all zeros to the end while maintaining the order of non-zero elements.

The key idea is to process the list in one pass, apply transformations, and then separate non-zero elements while shifting zeros to the end.
# Approach
<!-- Describe your approach to solving the problem. -->
1. Iterate Through the Array
    - Traverse nums from index 0 to n-2.
    - If nums[i] == nums[i+1], double nums[i] and set nums[i+1] to zero.
    - Store the non-zero numbers in a new list r.
2. Handle the Last Element
    - If nums[n-1] is not zero, append it to r.
3. Shift Zeros to the End
    - Compute the number of missing elements (n - len(r)) and append that many zeros.
4. Return the Modified List
    - Concatenate r (non-zero elements) with zeros to maintain O(n) complexity.
# 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
```python3 []
class Solution:
    def applyOperations(self, nums: List[int]) -> List[int]:
        r=[]
        n=len(nums)
        for i in range(n-1):
            if nums[i]==0:
                continue
            if nums[i]==nums[i+1]:
                nums[i]*=2
                nums[i+1]=0
                r.append(nums[i])
            else:
                r.append(nums[i])
        if nums[n-1]!=0:
            r.append(nums[n-1])
        zl=[0]*(n-len(r))
        print(r)
        nums=r+zl
        return nums
```
['Python3']