c++ || stack
\nclass Solution {\npublic:\n    int minDeletion(vector<int>& nums) {\n        bool k = false;\n        int n = nums.size();\n        if(n%2==0) k=true;\n      
```\nclass Solution {\npublic:\n    int minDeletion(vector<int>& nums) {\n        bool k = false;\n        int n = nums.size();\n        if(n%2==0) k=true;\n        \n        stack<int> st;\n        int p=0;\n        st.push(nums[p++]);\n        int count=0;\n        while(p < n){\n            if((st.size()-1)%2==0 && nums[p]==st.top()){\n                count++;\n                p++;\n                k = !k;\n            }\n            else{\n                st.push(nums[p]);\n                p++;\n            }\n        }\n        if(k) return count;\n        else return count+1;\n    }\n};\n```
[]