Sir, i have created the code but I am getting an extra node value in test case ,could you share me the code for the program so i could just debug it
Error in the code
Hey @siddhant_samal
You have to build tree with level order input
node *buildTree()
{
int d;
cin>>d;
queue<node *>q;
node *root=new node(d);
q.push(root);
int c1,c2;
while(!q.empty())
{
node *f=q.front();
q.pop();
cin>>c1>>c2;
if(c1!=-1)
{
f->left=new node(c1);
q.push(f->left);
}
if(c2!=-1)
{
f->right=new node(c2);
q.push(f->right);
}
}
return root;
}
i am unable to understand the code you sended…could you make changes in my code?? …how you are taking cin>
Hey @siddhant_samal
You have to create tree like this only because input is coming level wise
I can’t change ur code because u are inputting it in normal way
I think there was some technical glitch
See this
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

