Java. Stack. Baseball Game
\n\nclass Solution {\n    public int calPoints(String[] operations) {\n        Stack<Integer> stack = new Stack<>();\n        for(String step : operations)\n   
\n```\nclass Solution {\n    public int calPoints(String[] operations) {\n        Stack<Integer> stack = new Stack<>();\n        for(String step : operations)\n        {\n            switch (step)\n            {\n                case "+":\n                {\n                    int second = stack.pop();\n                    int first = stack.peek();\n                    stack.push(second);\n                    stack.push(second + first);\n                    break;\n                }\n                case "D": {\n                    stack.push(stack.peek() * 2);\n                    break;\n                }\n                case "C":\n                {\n                    stack.pop();\n                    break;\n                }\n                default:\n                    stack.push(Integer.parseInt(step));\n            }\n        }\n        int sum = 0;\n        while (stack.size() > 0)\n            sum += stack.pop();\n        return sum;\n    }\n}\n```
['Java']