Beautiful array using 2 methods
Method 1: using shifting of indexes\nclass Solution {\n    public int minDeletion(int[] nums) {\n        int count = 0;\n        for(int i=0;i<nums.length-1;i++
Method 1: using shifting of indexes\nclass Solution {\n    public int minDeletion(int[] nums) {\n        int count = 0;\n        for(int i=0;i<nums.length-1;i++){\n            int m = i - count;\n            if(m%2 == 0 && nums[i] == nums[i+1]){\n                count++;\n            }\n        }\n        \n        if((nums.length - count) % 2 == 0)\n            return count;\n        return count+1;\n        \n    }\n}\n\n\n\nMethod 2 : Using arraylist(relatively high run time)\n\nclass Solution {\n    public int minDeletion(int[] nums) {\n        List<Integer> result = new ArrayList<Integer>();\n        int count = 0;\n        \n        for(int i : nums)\n            result.add(i);\n        \n        for(int i=0;i<result.size()-1;i++){\n            int x = result.get(i);\n            int y = result.get(i+1);\n            if(i%2 == 0 && x == y){\n                result.remove(i);\n                count++;\n                i = i - 1;\n            }\n        }\n\n        if(result.size() % 2 == 0)\n            return count;\n        return count+1;\n    }\n}
['Java']