150. 逆波兰表达式求值
#include <vector> #include <unordered_map> #include <string> #include <algorithm> #include <stack> #include <queue>using namespace std;class Solution { public:int evalRPN(vector<string>& tokens) {stack<int> st;for (int i = 0; i < tokens.size(); i++) {if (tokens[i] == "+" || tokens[i] == "-" || tokens[i] == "*" || tokens[i] == "/") {int right = st.top();st.pop();int left = st.top();st.pop();if (tokens[i] == "+") st.push(left + right);if (tokens[i] == "-") st.push(left - right);if (tokens[i] == "*") st.push(left * right);if (tokens[i] == "/") st.push(left / right);}else {st.push(stoi(tokens[i]));}}return st.top();} };//这题踩的坑: //left和right反了,因为是用的栈存储,所以先提出来的是右值//要注意的点 //字符串转别的类型是 ato() //比如转int就是atoi,转long long就是atoll
239. 滑动窗口最大值
347.前 K 个高频元素