Easy Java Solution with Stack
Approach1: Use Stack\n# Approach2: Use Dequeue\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity: O(n)\n Add your time comple
# Approach1: Use Stack\n# Approach2: Use Dequeue\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\nclass Solution {\n    public int calPoints(String[] operations) {\n\n        Stack<Integer> stack = new Stack<>();\n        \n        for(int i=0; i<operations.length; i++){\n            if(operations[i].equals("C")){\n                stack.pop();\n            }else if(operations[i].equals("D")){\n                stack.push(stack.peek() * 2);\n            }else if(operations[i].equals("+") && stack.size()>=2){\n                int value1 = stack.pop();\n                int value2 = stack.pop();\n                int value = value1+ value2;\n                //push value2 back to the stack frist\n                stack.push(value2);\n                stack.push(value1);\n                stack.push(value);\n            }else {\n                stack.push(Integer.parseInt(operations[i]));\n            }\n        }\n        \n        System.out.println("Stack" + stack);\n\n        int sum =0;\n        while (!stack.isEmpty()){\n            sum += stack.pop();\n        }\n        \n        return sum;\n    }\n}\n```
['Stack', 'Java']