Stack *s = new Stack();
for (int i = 0; i < strlen(str): i++)
{
if ((str[i] == '{') || (str[i] == '[') || (str[i] == '('))
s->push(str[i]);
else
{
char tp = s->pop(); // get the element at top
if (tp == '{') && (sir[i] != '}')
return false;
if (tp == '[') && (sir[i] != ']')
return false;
if (tp == '[') && (sir[i] != ']')
return false;
}
if (s->empty())
return true;
return false;
}