EASY JAVA SOLUTION || USING STACK || WITH EXPLANATION || CLEAN CODE
\n\nclass Solution {\n    \n    public int calPoints(String[] ops) {\n        \n        Stack<Integer> s= new Stack<>();\n        for(int i=0;i<ops.length;i++){
\n```\nclass Solution {\n    \n    public int calPoints(String[] ops) {\n        \n        Stack<Integer> s= new Stack<>();\n        for(int i=0;i<ops.length;i++){\n            // ATQ--> "C" is encountered simple pop the element.\n            if(ops[i].equals("C")){\n                s.pop();\n            }\n            // ATQ-->"D" is encountered while traversing the string we push into stack 2*s.peek() element .\n            else if(ops[i].equals("D")){\n                s.push(2*s.peek());\n            }\n            //ATQ-->  "+" is encountered in the ops array we pop two element then add their sum and again push the popped items with their sum.\n            else if(ops[i].equals("+")){\n                int sum=0;\n                int s1=s.pop();\n                int s2=s.pop();\n                sum=s1+s2;\n                s.push(s2);\n                s.push(s1);\n                s.push(sum);\n            }\n            // ATQ--> if the element is digit simply push the element in stack\n            else{\n                s.push(Integer.parseInt(ops[i]));\n            }\n        }\n        \n        // finally pop all the element from stack & return their sum\n        int sumofStack=0;\n        while(!s.isEmpty()){\n            sumofStack=sumofStack+s.pop();\n        }\n        \n        // return their sum\n        return sumofStack;\n        \n    }\n}\n```
['Stack', 'Java']