JAVA | O(1) space | Easy to Understand
\nclass Solution {\n    public int minDeletion(int[] nums) {\n        \n        int i = 0, n = nums.length;\n        int currIndex = 0;\n        if(nums.length=
```\nclass Solution {\n    public int minDeletion(int[] nums) {\n        \n        int i = 0, n = nums.length;\n        int currIndex = 0;\n        if(nums.length==1) return 1;\n        int count = 0;\n        while(i<n){\n            if(currIndex%2==0){  // if index is even then delete all the continuous duplicate elements to the right of it\n                \n                int k = nums[i];\n                while(i+1<nums.length && nums[i+1]==k){\n                    i++;\n                    count++;\n                }\n                \n            }\n            \n            i++;\n            currIndex++;  // this is the virtual index of new array which will be created after shifting the elemnts to left\n            \n            \n        }\n        \n        if(currIndex%2==0){  \n            return count;\n        }\n        else{\n            return count+1;  // if the length of new array is odd then just delete last element to make length even\n        }\n    }\n}\n```
['Java']