You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 following types: Integer (one round's score): Directly represents the number of points you get in this round. "+" (one round's score): Represents…
You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 following types: Integer (one round's score): Directly represents the number of points you get in this round. "+" (one round's score): Represents…
class Solution { public: int calPoints(vector<string>& ops) { stack<int> ST; ; for (auto o : ops) { if (o == "C") { int n = ST.top(); sum -= n; ST.pop(); } else if (o == "D") { ; sum += n; ST.push(n); } else if (o == &q…