class ChkExpression {
public:
bool chkLegal(string A) {
// write code here
int num = A.length();
int arr[8] = {0};
int num1=0;
while(num)
{
if(A[num1]=='(')
arr[0]++;
else if(A[num1]==')')
arr[1]++;
else if(A[num1]=='{')
arr[2]++;
else if(A[num1]=='}')
arr[3]++;
else if(A[num1]=='[')
arr[4]++;
else if(A[num1]==']')
arr[5]++;
num1++;
num--;
}
if(arr[0]==arr[1]&&arr[2]==arr[3]&&arr[4]==arr[5])
return true;
else
return false;
}
};