class Solution {
public:
char a[10005];
int pos=0;;
bool isValid(string s) {
if(s.length()==0)
return true;
for(int i=0;i<s.length();i++)
{
if(pos==0)
{
a[pos++]=s[i];
continue;
}
else
{
if(a[pos-1]=='('&&s[i]==')')
{
pos--;
continue;
}
else if(a[pos-1]=='['&&s[i]==']')
{
pos--;
continue;
}
else if(a[pos-1]=='{'&&s[i]=='}')
{
pos--;
continue;
}
else
a[pos++]=s[i];
}
}
if(pos!=0)
return false;
else
return true;
}
};