JAVA very concise and easy to understand using stack
\n    public int calPoints(String[] ops) {\n        int sum = 0;\n        Stack stack = new Stack();\n        for(int i = 0; i < ops.length; i++)\n        {\n  
\n    public int calPoints(String[] ops) {\n        int sum = 0;\n        Stack<Integer> stack = new Stack<Integer>();\n        for(int i = 0; i < ops.length; i++)\n        {\n            if(ops[i].equals("+"))\n            {\n                int temp1 = stack.pop();\n                int temp2 = stack.pop();\n                int temp_sum = temp1 + temp2;\n                sum += temp_sum;\n                stack.push(temp2);\n                stack.push(temp1);\n                stack.push(temp_sum);\n            }\n            else if(ops[i].equals("D"))\n            {\n                int temp = stack.pop();\n                int temp_d = 2 * temp;\n                sum += temp_d;\n                stack.push(temp);\n                stack.push(temp_d);\n            }\n            else if(ops[i].equals("C"))\n            {\n                int cancel = stack.pop();\n                sum -= cancel;\n            }\n            else\n            {\n                int temp = Integer.parseInt(ops[i]);\n                sum += temp;\n                stack.push(temp);   \n            }\n        }\n        return sum;\n    }
[]