My Accepted Code in Java 7ms
My idea is that just keeping track of the current valid round's point in an array and use it to have a next valid round's point.\n\n```\n  public int calPoints(
My idea is that just keeping track of the current valid round's point in an array and use it to have a next valid round's point.\n\n```\n  public int calPoints(String[] ops) {\n    int sum = 0;\n    int valid[] = new int[ops.length];\n    int v = -1;\n    for (int i = 0; i < ops.length; i++) {\n      if (ops[i].equals("C")) {\n        sum -= valid[v];\n        v--;\n      } else if (ops[i].equals("D")) {\n        int d = (valid[v] + valid[v]);\n        v++;\n        valid[v] = d;\n        sum += d;\n      } else if (ops[i].equals("+")) {\n        int p = (valid[v] + valid[v - 1]);\n        v++;\n        valid[v] = p;\n        sum += p;\n      } else {\n        int val = Integer.parseInt(ops[i]);\n        v++;\n        valid[v] = val;\n        sum += val;\n      }\n    }\n\n    return sum;\n  }\n````
[]