20. 有效的括号
方法:
	1.   如果 !st.empty()  return false

		2.如果st.top() != s[i]   return false

	3. 如果  st.empty()   return false

注意: 以下这种写法 不满足 题目要求的第二点,不能以正确的顺序闭合
            if(s[i] == st.top()){return true;st.pop();}

代码:
class Solution {
public:bool isValid(string s) {stack<char>st;for(int i=0;i<s.size(); i++){if(s[i] == '('){st.push(')');}else if(s[i] == '{'){st.push('}');}else if(s[i] == '['){st.push(']');}else if(st.empty() ||s[i] != st.top()  ){return false;}else{st.pop();}}if(st.empty()){return true;}return false;// return st.empty();       }
};

1047. 删除字符串中的所有相邻重复项
方法:栈
	定义栈st遍历整个s,如果st是空  或者  st.top() != s[i]   则将s[i]加入栈st中。否则  st.top() == s[i]  弹出st.top();
注意:
代码:
class Solution {
public:string removeDuplicates(string s) {stack<char>st;for(int i=0; i<s.size(); i++){if(st.empty() || st.top()!= s[i]){st.push(s[i]);}else{st.pop();}}string res;while(!st.empty()){res+=st.top();st.pop();}reverse(res.begin(), res.end());return res;}
};

150. 逆波兰表达式求值
方法: 栈
注意:逆波兰表达式 注意 加减乘除顺序 是s2+s1 s2-s1 s2*s1 s2/s1
代码:
class Solution {
public:int evalRPN(vector<string>& s) {stack<long long >st;for(int i=0; i<s.size(); i++){if(s[i] != "+" && s[i] != "-" && s[i] != "*" && s[i] != "/"){st.push(stoll(s[i])); }else if(s[i] == "+"||s[i] == "-" || s[i] == "*"||  s[i] == "/"  ){long long s1 = st.top();cout<< "s1  " <<s1<<endl;st.pop();long long s2 = st.top();cout<<"s2  " <<s2<<endl;st.pop();  if(s[i] == "+"){ st.push(s1+ s2);}if(s[i] == "-"){ st.push( s2-s1);}if(s[i] == "*"){ st.push( s2*s1);}  if(s[i] == "/"){ st.push( s2 /s1);}           }}int ans = st.top();st.pop();return ans;}
};
