题目:

题解:
class Solution {
public:
bool isValid(string s) {
int n = s.size();
if (n % 2 == 1) {
return false;
}
unordered_map<char, char> pairs = {
{')', '('},
{']', '['},
{'}', '{'}
};
stack<char> stk;
for (char ch: s) {
if (pairs.count(ch)) {
if (stk.empty() || stk.top() != pairs[ch]) {
return false;
}
stk.pop();
}
else {
stk.push(ch);
}
}
return stk.empty();
}
};









![新型[datahelper@onionmail.org].datah 勒索病毒来袭:如何筑起安全防线?](https://img-blog.csdnimg.cn/direct/a5e777b69da9441a9a3280b99526fcd4.jpeg)









