Open Zheaoli opened 1 year ago
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
/*
* @lc app=leetcode.cn id=2011 lang=cpp
*
* [2011] 执行操作后的变量值
*/
// @lc code=start
class Solution
{
public:
unordered_map<string, int> map = {{"X++", 1}, {"++X", 1}, {"--X", -1}, {"X--", -1}};
int finalValueAfterOperations(vector<string> &operations)
{
int res = 0;
for (auto &&op : operations)
{
res += map[op];
}
return res;
}
};
// @lc code=end
微信id: 而我撑伞 来自 vscode 插件
2022-12-23