✅Two Simple Java Solutions || ✅Runtime 0ms || ✅ Beats100%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code 1\n```\nclass Solution {\n    public int calPoints(String[] operations) \n    {\n        int output = 0;\n\n        int[] list = new int[operations.length];\n\n        for (int i = 0 , j = -1; i < operations.length ; i++)\n        {\n            if (operations[i].equals("C"))\n            {\n                list[j] = 0;\n                j--;\n            }else if (operations[i].equals("D")){\n                j++;\n                list[j] = 2 * (list[j-1]) ;\n            }else if (operations[i].equals("+")){\n                j++;\n                list[j] = (list[j-1] + list[j-2] );\n            }else {\n                j++;\n                list[j] = (Integer.parseInt(operations[i]));\n            }\n\n        }\n\n        for (int n : list){\n            output += n;\n        }\n\n\n        return output;\n    }\n}\n```\n\n# code 2 :  By LinkedList \n\n```\nclass Solution {\n    public int calPoints(String[] operations) {\n          int output = 0;\n\n        LinkedList<Integer> list = new LinkedList<>();\n\n        for (int i = 0 , j = 0; i < operations.length ; i++)\n        {\n            if (operations[i].equals("C"))\n            {\n                list.removeLast();\n                j--;\n            }else if (operations[i].equals("D")){\n                list.add( 2 * (list.getLast()) );\n                j++;\n            }else if (operations[i].equals("+")){\n                list.add(list.getLast() + list.get(j-2));\n                j++;\n            }else {\n                list.add(Integer.parseInt(operations[i]));\n                j++;\n            }\n\n        }\n\n        for (int n : list){\n            output += n;\n        }\n\n\n        return output;\n    }\n}\n```\n\n## For additional problem-solving solutions, you can explore my repository on GitHub: [GitHub Repository](https://github.com/ahmedna126/java_leetcode_challenges)\n\n\n![e78315ef-8a9d-492b-9908-e3917f23eb31_1674946036.087042.jpeg](https://assets.leetcode.com/users/images/97ba9f47-f35a-46fe-8890-60103b85cc26_1693003538.1619122.jpeg)\n
['Java']