```
public:
bool isValid(string s) {
stack<char> result;
for(int i=0; i<s.length(); i++)
{
if(s[i]==')' || s[i]==']' || s[i]=='}')
{
if(result.top()==s[i]-1 || result.top()==s[i]-2)
result.pop();
else
return false;
}
else
result.push(s[i]);
}
if(!result.empty()) return false;
return true;
};
**Can someone explain to me?Thx very much!!**
```