堆栈
class Solution {
public:
bool isValid(string s) {
stack<char>t;
for(char i:s){
if(t.empty())t.emplace(i);
else if(t.top()=='('&&i==')')t.pop();
else if(t.top()=='['&&i==']')t.pop();
else if(t.top()=='{'&&i=='}')t.pop();
else t.emplace(i);
}
return t.empty()?1:0;
}
};