✅ Java Easy Solution ✅
\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n\n- Space complexity:
\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[] applyOperations(int[] nums) {\n        for(int i = 0; i < nums.length-1; i++) {\n            if(nums[i] == nums[i+1]) {\n                nums[i] = nums[i]*2;\n                nums[i+1] = 0;\n            }\n        }\n        \n        int[] result = new int[nums.length];\n        int k = 0;\n        for(int i = 0; i < nums.length; i++) {\n            if(nums[i] != 0)\n                result[k++] = nums[i];\n        }\n        \n        return result;\n    }\n}\n```
['Java']