# Subtree Of Another Tree Leetcode

inorder array is not accepting char even after typecasting

Help!!

Hey @Bhawna

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);

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

1 Like