cpp best solution
Intuition\nCpp best solution\n\n# Approach\nvector\n\n# Complexity\n- Time complexity:\n(o)n\n\n- Space complexity:\n(o)n\n\n# Code\n\nclass Solution {\npublic:
# Intuition\nCpp best solution\n\n# Approach\nvector\n\n# Complexity\n- Time complexity:\n(o)n\n\n- Space complexity:\n(o)n\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> applyOperations(vector<int>& nums) {\n        \n        int res=0;\n        \n        for(int i=0;i<nums.size()-1;i++)\n        {\n            if(nums[i]==nums[i+1])\n            {\n                nums[i+1]=0;\n                nums[i]*=2;\n            }\n            if(nums[i]==0)\n                res++;\n        }\n        \n        if(nums[nums.size()-1]==0)\n            res++;\n            // leet code\n        \n        vector<int> flag;\n        for(auto i:nums)\n            if(i>0)\n                flag.push_back(i);\n        \n        for(int i=0;i<res;i++)\n            flag.push_back(0);\n        \n        \n        \n        return flag;\n}\n};\n```
['C++']