[Java] Stack
\nclass Solution {\n\n  public int minDeletion(int[] nums) {\n    Deque<Integer> stack = new ArrayDeque();\n    int delete = 0;\n    for (int num : nums) {\n   
```\nclass Solution {\n\n  public int minDeletion(int[] nums) {\n    Deque<Integer> stack = new ArrayDeque();\n    int delete = 0;\n    for (int num : nums) {\n      if (stack.size() % 2 == 0) {\n        stack.push(num);\n      } else {\n        if (stack.peek() == num) {\n          delete++;\n        } else {\n          stack.push(num);\n        }\n      }\n    }\n    return stack.size() % 2 == 0 ? delete : delete + 1;\n  }\n}\n```
['Java']