class Solution {
public:
/**
*
* @param s string字符串
* @return bool布尔型
*/
bool isValid(string s) {
// write code here
if(s.length()%2!=0) return false;
stack<char> st;
for(int i=0;i<s.length();i++){
if(st.size()==0){
st.push(s[i]);
}else{
if(st.top()=='('&&s[i]==')') st.pop();
else if(st.top()=='['&&s[i]==']') st.pop();
else if(st.top()=='{'&&s[i]=='}') st.pop();
else st.push(s[i]);
}
}
return st.size()==0;
}
};