diff options
Diffstat (limited to 'baseball_game.cpp')
-rw-r--r-- | baseball_game.cpp | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/baseball_game.cpp b/baseball_game.cpp deleted file mode 100644 index f5d1b35..0000000 --- a/baseball_game.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - int calPoints(vector<string> &ops) { - int val1, val2, ans = 0; - stack<int> s; - for (string i : ops) { - if (i == "C") - s.pop(); - else if (i == "D") - s.push(s.top() * 2); - else if (i == "+") { - val1 = s.top(); - s.pop(); - val2 = s.top(); - s.push(val1); - s.push(val1 + val2); - } else - s.push(stoi(i)); - } - while (s.size() != 0) { - ans += s.top(); - s.pop(); - } - return ans; - } -}; - -int main() {} |