Easy understanding
All we have to is \n1. if (ind % 2 == 0) then nums[i] != nums[i + 1]\n2. final length of array must be even\n\n- For requirement 1,\nwe keep track of elements(i
All we have to is \n1. if (ind % 2 == 0) then nums[i] != nums[i + 1]\n2. final length of array must be even\n\n- For requirement 1,\nwe keep track of elements(index), we see if the 1st condition holds or not, if not remove them(deletion++).\n\n\n- For requirement 2,\nWe just have to check result array\'s length, if even - its fine, if not - deletion++;\n\nWe don\'t have to make result array here as we don\'t need it. We just need some information and that we can hold in variables. \nAs we are removing elements, we have to keep track of index in result array.\n\n**Understanding variables used in algo**\n\nindRes - As we are deleting element on going, we have to keep track of elements that we are keeping for final result, You can also take it as current index of result(beautiful) array as index\n\nind - index of given array\n\ndeletion - number of deletion, we are making\n\n```\n\nclass Solution {\n    public int minDeletion(int[] nums) {\n        int indRes = 0;\n        int ind = 0;        \n        int deletion = 0;\n        \n        while (ind < nums.length - 1) {\n            \n            //check 1st condition\n            if (indRes % 2 == 0) {      //check what index is this in result array\n                int next = ind + 1;\n                while (next < nums.length && nums[ind] == nums[next]) {\n                    deletion++;\n                    next++;\n                }\n                ind = next;\n            } else {\n                ind++;                  //not doing anything for odd index\n            }\n            indRes++;                   //index in result array increses\n        }\n        \n        \n        //manage last elemets of given array\n        if (ind < nums.length) {\n            indRes++;\n        }\n        \n        //2nd consition\n        if (indRes % 2 != 0) {\n            deletion++;\n        }\n        \n        return deletion;\n    }\n}\n```\n\nTC - O(N)\nSC - O(1)\n\nUpvote if you find this helpful.
[]