Intuition Easy (EVEN ODD)
The main catch for the problem is nums.length should be even after all of the operation \nObserve a pattern \nafter the operation\n1 . nums.length is odd (5)  -
The main catch for the problem is nums.length should be even after all of the operation \nObserve a pattern \nafter the operation\n1 . nums.length is odd (5)  -> 0 1 2 3 4\n2 . nums.length is even (6) -> 0 1 2 3 4 5\nnow lets suppose we have done some operation optimally and our ans vector size at this point of time is odd thats means we have a even index at the end so we need to make sure that the next element we are inserting in our ans vector should not be same as the last one\nand is its even we can simply insert the element because at the even size our last element will always be at odd index (we dont care about it).. and simply after traversing the whole array we have our ans if ans size is odd (total - ans.size()-1) else {total-ans.size()}\n\nSpace optimization : easy (try it yourself)\n```\nclass Solution {\npublic:\n    int minDeletion(vector<int>& nums) {\n        int n = nums.size();\n        vector<int>ar;\n        ar.push_back(nums[0]);\n        for (int i = 1 ; i<n ; i++){\n            if (ar.size()%2 == 1){\n                if (ar.back() == nums[i]){continue;}\n                else{\n                    ar.push_back(nums[i]);\n                }\n            }\n            else{\n                ar.push_back(nums[i]);\n            }\n        }\n        if (ar.size()&1) ar.pop_back();\n        return (n-(int)ar.size());\n    }\n};\n```\n
['Greedy']