Only one test cases is passing.
what is the error in this code?
Here is the implementation :
Only one test cases is passing.
what is the error in this code?
Here is the implementation :
@lakshyatoshniwal
you didn’t had to sort the given array before constructing the BST. The BST is to be constructed in the given sequence only.
I have constructed the tree in given order only. As we are given preorder sequence of the BST, I have found inorder traversal by sorting the sequence and then from both the sequences I have constructed tree. The constructed tree is correct and I have verified it by printing inorder, preorder and level order traversal of it.
@lakshyatoshniwal the given sequence is not preorder sequence , its just an array that you have to insert in bst val by val