bool isValid(char * s){ char a[3500]; int current = -1; for(int i = 0;i < strlen(s);i++){ if(s[i] == '(' || s[i] == '[' || s[i] == '{'){ current++; a[current] = s[i]; } else{ if(current < 0) return false; if(s[i] == ')'){ if(a[current] == '(') current--; else return false; } if(s[i] == ']'){ if(a[current] == '[') current--; else return false; } if(s[i] == '}'){ if(a[current] == '{') current--; else return false; } } } if(current < 0) return true; else return false; }