表达式中只含有‘1‘-‘9‘,‘+’,‘-’,‘(’,‘)’,空格这些字符
class Solution {
public:
int calculate(string s) {
int fast=0;
int slow=0;
int size=s.length();
while(fast<size){
if(s[fast]!=' ')
s[slow++]=s[fast];
++fast;
}
stack<char> st;
vector<char> res;
for(auto &e:s){
if(e==')'){
while(!st.empty()&&st.top()!='('){
res.push_back(st.top());
st.pop();
}
st.pop();
}else if(e=='('){
st.push(e);
}else if(e=='+'||e=='-'){
while(!st.empty()&