JAVA | Clean and Simple ✅
Please Upvote :D\n\nclass Solution {\n    public int calPoints(String[] operations) {\n        Stack<Integer> stack = new Stack<>();\n\n        for (String s : 
### **Please Upvote** :D\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                int a = stack.pop();\n                int newScore = a + stack.peek();\n                stack.push(a);\n                stack.push(newScore);\n            }\n            else if (s.equals("D")) {\n                stack.push(2 * stack.peek());\n            }\n            else if (s.equals("C")) {\n                stack.pop();\n            }\n            else stack.push(Integer.parseInt(s));\n        }\n\n        int totalScore = 0;\n        while (!stack.isEmpty()) totalScore += stack.pop();\n\n        return totalScore;\n    }\n}\n\n// TC: O(n), SC: O(n)\n```
['Stack', 'Java']