Two Pointers
This problem may look harder than it is. We just need to realize that we always have to delete if two consecutive elements (after the shift) are equal.\n\nWe ca
This problem may look harder than it is. We just need to realize that we always have to delete if two consecutive elements (after the shift) are equal.\n\nWe can use the two-pointer approach to track the shift (`j`).\n\n**C++**\n```cpp\nint minDeletion(vector<int>& nums) {\n    int j = 0, sz = nums.size();\n    for(int i = 0; i - j + 1 < sz; i += 2)\n        j += nums[i - j] == nums[i - j + 1];\n    return j + (sz - j) % 2;\n}\n```
['C']