Apply Operations to an Array
Here is a Python solution that implements this behavior. It iterates over the array and applies the operations as described. After that, it moves all zeros to the end of the array.


In this solution, we iterate through the list of numbers. If the current number is the same as the next one, we double the current number and set the next number to 0. After performing all these operations, we filter out all nonzero numbers and create a new list. The remaining slots in the list are filled with zeros. This effectively moves all zeros to the end of the list.
Readable Solution


This code first updates the array based on the condition that if two consecutive numbers are equal, then it multiplies the first number by 2 and sets the second number to 0. Then it collects all nonzero values at the front and sets remaining values to zero. The final array is then returned.