Java Solution with Intuition
Intuition\n\nIf we analyse the problem a little, we\'ll see that its indirectly asking us to create a new array after the deletions. Since its not asking for an
**Intuition**\n\nIf we analyse the problem a little, we\'ll see that its indirectly asking us to create a new array after the deletions. Since its not asking for an actual array to be returned, but rather the number of deletions, we need not create an actual array, we can just simulate its creation. \n\nFor this purpose, I am using `j` as the `starting index of the new array`. Before adding any value to my new array from `nums` by incrementing `j`, I first check whether index `j` is satisfying the second condition. In the end, we keep a length check to satisfy the first condition.\n\n```\n    public int minDeletion(int[] nums) {\n        int count = 0, j = 0;\n        \n        for (int i = 0; i < nums.length - 1; i++) {  \n            \n            if (j % 2 == 0 && nums[i] == nums[i + 1]) {\n                count++;\n            } else {\n                j++;\n            }\n        }\n        \n        // odd length array\n        if ((j + 1) % 2 == 1) {\n            count++;\n        }\n        \n        return count;\n    }\n```
['Java']