inorder array is not accepting char even after typecasting
Code Link-https://ide.geeksforgeeks.org/cwBJyKSgwz
Help!!
inorder array is not accepting char even after typecasting
Code Link-https://ide.geeksforgeeks.org/cwBJyKSgwz
Help!!
Hey @Bhawna
Your code is working without any compilation error on my side,please elaborate your doubt
Getting wrong answer using same code
Hey @Bhawna
Updated this https://ide.codingblocks.com/s/357290
But this will only work when nums are between 0-9 but this is not the case here,so u have to take strings instead and solve it using strings instead of char array
Or
convert ever digit of the number to char and then insert it into char array
for -54 insert - then 5 then 4
its much complex in char array
pre[i]=root->val+‘0’; //Updated this
pre[i++]='L'; //added this
preorder(root->left,pre,i);
pre[i++]='R';//added this
preorder(root->right,pre,i);
I didn’t understand above clearly
This is converting an integer digit to char digit
Whenever we go left sub node we add L to our array
Similarly for R
otherwise say
1
2
3
this and
1
2
3
will have same array
After handling Negative Integers ,I got AC…Thanks
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.