Subtree Of Another Tree Leetcode

inorder array is not accepting char even after typecasting

Code Link-

Hey @Bhawna
Your code is working without any compilation error on my side,please elaborate your doubt :slight_smile:

Getting wrong answer using same code

Hey @Bhawna
Updated this
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

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


     pre[i++]='R';//added this


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

this and 
will have same array

After handling Negative Integers ,I got AC…Thanks

1 Like

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.