java o(n) brute force approach
\nclass Solution {\n    public static int calPoints(String[] ops) {\n        int i = 0;\n        ArrayList<Integer> arr=new ArrayList<>();\n        for (int j =
```\nclass Solution {\n    public static int calPoints(String[] ops) {\n        int i = 0;\n        ArrayList<Integer> arr=new ArrayList<>();\n        for (int j = 0; j < ops.length; j++) {\n            char ch= ops[j].charAt(0);\n            if(ops[j].charAt(0)!=\'C\' && ops[j].charAt(0)!=\'D\' && ops[j].charAt(0)!=\'+\') arr.add(Integer.parseInt(ops[j]));\n            if(ops[j].charAt(0)==\'C\') arr.remove(arr.size()-1);\n            else if(ops[j].charAt(0)==\'D\') arr.add(2*arr.get(arr.size()-1));\n            else if(ops[j].charAt(0)==\'+\') arr.add((arr.get((arr.size()-1))+arr.get((arr.size()-2))));\n        }\n        int sum=0;\n        for(int i1:arr) sum+=i1;\n        return sum;\n    }\n}\n```
['Java']