I am failing perf 4, the input seems to be quite big, how can i debug this test case. It is the only one failing.
Hey it looks like you are traversing the inorder all the time to find the rootval. I would suggest using a hash map so that you remove this part. So your complexity willl reduce drastically.
I previously did using a hash map but i was failing perf 7, 8 and 9 then I followed this post
You can optimize the search by searching only from
iend instead of the entire inorder list. I hope this is a good enough optimization in this case.
I followed your suggestion to adjust for loop limit from istart to iend for inorder array search however this gives a stack overflow exception.
i fixed the isue and thanks it worked.
Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.