c++ solution || two approaches|| O(1) space
Using stack :\n\nclass Solution {\npublic:\n    int minDeletion(vector<int>& a) {\n        stack<int>s;\n        int n=a.size(),index=-1,count=0;\n        for(i
Using stack :\n```\nclass Solution {\npublic:\n    int minDeletion(vector<int>& a) {\n        stack<int>s;\n        int n=a.size(),index=-1,count=0;\n        for(int i=0;i<n;i++){\n            if(!s.empty() && a[i]==s.top() && index%2==0){\n                count++;\n            }\n            else{\n                index++;\n                s.push(a[i]);\n            }\n        }\n        if(index%2==0)\n            count++;\n        return count;\n    }\n};\n```\nUsing two pointer .. O(1) space:\n```\nclass Solution{\npublic:\nint minDeletion(vector<int>&a){\nint n=a.size();\nint count=0;\nfor(int i=0;i<n-1;i++){\n\t\tint index=i-count;\n\t//  since the index keeps changing after every deletion \n\t\tif(a[i+1]==a[i] && index%2==0)\n\t\t\tcount++;\n}\n\t\tif((n-count)%2!=0)\n\t\t\tcount++;\n\t\treturn count;\n\t}\n};\n```
['Stack', 'C']