C++/Python | Intuituitive | Easy to Understand | Two Pointers | O(n) Solution
Intuition\n We have to take care of new index formed after deletion so let\'s mantain another pointer j\n We have pointer i for traversing in the array\n As sta
**Intuition**\n* We have to take care of new index formed after deletion so let\'s mantain another pointer j\n* We have pointer i for traversing in the array\n* As stated, if nums[i] == nums[i+1] and j%2 == 0 we have to perform deletion, as we are oerforming deletion size reduces so no need to increament j\n* At last after traversing whole array if size is odd then we have to perform one more deletion\n\n***C++***\n```\nclass Solution {\npublic:\n    int minDeletion(vector<int>& nums) {\n        int n = nums.size();\n        int j = 0, i = 0;\n        int del = 0;\n        while(i < n) {\n            if(i+1 < n && nums[i] == nums[i+1] && j%2 == 0) {\n                ++del;\n            } else {\n                ++j;\n            }\n            ++i;\n        }\n        if(j%2 != 0)\n            ++del;\n        return del;\n    }\n};\n```\n\n***Python***\n```\nclass Solution:\n    def minDeletion(self, nums: List[int]) -> int:\n        j = 0\n        i = 0\n        delete = 0\n        n = len(nums)\n        while i < n:\n            if (i+1 < n and nums[i] == nums[i+1] and j%2 == 0) :\n                delete += 1;\n            else:\n                j += 1;\n            i += 1\n        if j%2 != 0:\n            delete += 1\n        return delete\n            \n```\n**If you find this helpful upvote it, if you have any doubt than comment**
['Two Pointers', 'C', 'Python']