C++ | O(n) solution with comments
We just need to change the index after deletions to get the new index value in every iteration.\nUPVOTE  if you like it!!\n\n\nclass Solution {\npublic:\n    in
We just need to change the index after deletions to get the new index value in every iteration.\nUPVOTE  if you like it!!\n\n```\nclass Solution {\npublic:\n    int minDeletion(vector<int>& nums) {\n        if(nums.size()==1) return 1;\n        \n        int count=0;\n        int n=nums.size();\n        \n        for(int i=0; i<n-1; i++)\n        {\n\t\t//since after every deletion numbers should shift backward \n\t\t//to avoid shifting we only consider their newIndex to find out whether they are \n\t\t//odd or even in further iterations\n            int newIndex = i-count;\n            if(newIndex%2 == 0 && nums[i]==nums[i+1])\n                count++;\n        }\n\t\t\n\t\t//if remaining length is even then print count else delete one more element so count-1\n        if((n-count)%2 == 0)\n            return count;\n        else\n            return count+1;\n    }\n};\n```
['C']