One Pass
C++\ncpp\nvector<int> applyOperations(vector<int>& nums) {\n    vector<int> res(nums.size());\n    for(int i = 0, j = 0; i < nums.size(); ++i)\n        if (nums
**C++**\n```cpp\nvector<int> applyOperations(vector<int>& nums) {\n    vector<int> res(nums.size());\n    for(int i = 0, j = 0; i < nums.size(); ++i)\n        if (nums[i]) {\n            if (i < nums.size() - 1 && nums[i] == nums[i + 1]) {\n                res[j++] = nums[i] * 2;\n                nums[i + 1] = 0;\n            } \n            else if (nums[i])\n                res[j++] = nums[i];\n        }\n    return res;\n}\n```
['C']