Sir pls tell whats the error in this code

i was trying the question to build tree from inorder and postorder traversals and then write preorder traversal of tree…
here is my code-

the code is perfectly fine
when u run each case individually the o/p is correct
and in case of multiple test cases theere are a lot of garbage value
might be so that it depends on what memory locations are used to make the tree


doing it this way without taking test cases still works fine

in short u do not have to worry ur code is fine
its just that multiple test cases cause a problem

maam but how do i run the code… this question is from hacker blocks and they require multiple test cases… how do i make it running perfectly for multiple test cases

bro share hackerblock link for this question

https://hack.codingblocks.com/app/practice/2/608/problem

maam but what is wrong with my code… pls suggest changes in my code… u have sent a completely differently approached code( from geeks for geeks).

maam pls suggest changes to be done in my code to make it clear the test case

simply copying code from geeks and geeks would not help me build my understanding…

1 Like

meh btani hu ruko sir . give me 10 min

okay…sure ma’am… thanks

deleting chats??? i am still debugging

actually i dont know … suddenly they disappeared.

maybe some technical issue…

i have added comments instead of taking the static int i variable i have used a variable pos which i passed by reference and updates are made to it

the use of variable i was causing problem .

I`ll try to msg from my end please wait

okay… thanks a lot maam

i have msged from my end
please read the comments once and in case u have doubt u can ping back

maam but is there any specific reason that using static it gave garbage values… because sir in video used static variable only