bool checkNgoac(string temp) { int count1 = 0, count2 = 0, count3 = 0; //count1 - count { //count2 - count [ //count3 - count ( for (int i = 0;i < temp.length();i++) { if (temp[i] == 40) { count1++; } else if (temp[i] == 91) { count2++; } else if (temp[i] == 123){ count3++; } else if (temp[i] == 41) { count1--; } else if (temp[i] == 93) { count2--; } else if (temp[i] == 125) { count3--; } } if (count1 != 0 || count2 != 0 || count3 != 0) { return false; } return true; }