Brute Force  ✔   Easy Stack  ✔
Code\n\nclass Solution {\n    public int calPoints(String[] operations) {\n        Stack<Integer> stack = new Stack<>();\n\n        for (String s : operations) 
# Code\n```\nclass Solution {\n    public int calPoints(String[] operations) {\n        Stack<Integer> stack = new Stack<>();\n\n        for (String s : operations) {\n            if (s.equals("+")) {\n                stack.push(stack.peek() + stack.elementAt(stack.size()-2));\n            }\n            else if (s.equals("D")) {\n                stack.push(stack.peek() * 2);\n            }\n            else if (s.equals("C")) {\n                stack.pop();\n            }\n            else {\n                stack.push(Integer.parseInt(s));\n            }\n\n            //System.out.println(stack);\n        }\n\n\n        int sum = 0;\n\n        for (int i : stack) {\n            sum += i;\n        }\n\n        return sum;\n    }\n}\n\n// en \n//An integer x.\n//Record a new score of x.\n//\'+\'.\n//Record a new score that is the sum of the previous two scores.\n//\'D\'.\n//Record a new score that is the double of the previous score.\n//\'C\'.\n//Invalidate the previous score, removing it from the record.\n\n\n// uz\n// \'+\'. Oldingi ikki ballning yig\'indisi bo\'lgan yangi ball yozing.\n// \'D\'. Oldingi ballning ikki barobari bo\'lgan yangi ball yozing.\n// \'C\'. Oldingi ballni rekorddan olib tashlab, bekor qiling.\n\n```
['Stack', 'Java']