Easy Java Solution || Stack
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minDeletion(int[] arr) {\n        int ans = 0;\n        int n = arr.length;\n        Stack<Integer> st = new Stack<>();\n\n        for(int i=0; i<n; i++){\n            if(st.size()==0) st.push(arr[i]);\n            else{\n                if(st.peek()==arr[i]) ans++;\n                else st.pop();\n            }\n        }\n        ans = ans+st.size();\n        return ans;\n    }\n}\n```
['Java']