Can u tell me whether my method is correct or not?

I used a sorting technique to construct inorder array, will this take more than o(n) time?

hello @radhika1995

both the methods will take O(n^2) time.

because the method u are using to construct bst from given preorder and inorder has time complexity O(n^2).
and the sorrting algorithm u are using has time complexity O(n^2)

so overall time complexity will be O(n^2)

i made some changes in the code is this now in O

I made some changes in the code is this now in O(n) time? https://ide.codingblocks.com/s/222568

yeah this is O(n) now