Python3, solved in place
Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution:\n    def applyOperations(self, nums: List[int]) -> List[int]:\n  
# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution:\n    def applyOperations(self, nums: List[int]) -> List[int]:\n        zeros=0\n        nums+=[0]\n        for i in range(len(nums)-1):\n            if nums[i]==0:\n                zeros+=1\n            elif nums[i]==nums[i+1]:\n                nums[i-zeros]=nums[i]*2\n                nums[i+1]=0\n            else:\n                nums[i-zeros]=nums[i]\n            \n        return nums[:len(nums)-1-zeros] + [0]*zeros      \n```
['Python3']