Is Balanced Tree. Help needed in debugging

My code is failing test case 1. Could you please tell me where i am going wrong?

Your code is not working correctly for following test cases as,
Input : 50 true 12 true 18 false false false false
Your output : true
Expected Output : false

So for that pls change your buildtree function as ,

int x=0;
node *buildTree(node *&root)
{
if(x==0)
{
x++;
int k;
cin>>k;
root=new node(k);
root->left=buildTree(root->left);
root->right=buildTree(root->right);
return root;
}
else
{
string str;
cin>>str;
int d;
if(str==“true”)
{
cin>>d;
node *temp=new node(d);
temp->left=buildTree(temp->left);
temp->right=buildTree(temp->right);
return temp;
}
else
if(str==“false”)
{
return root;
}
}
return root;
}

and then try to submit…