The output is correct but it is not accepting
The output of the preorder is 4 2 3 5 6. It will depend on the tree?
Don’t sort the array before construction.
The array given in the input is not the preorder traversal of the BST to be formed. It is just a random unsorted array and you need to create a BST from the given unsorted array. The first element will be the root.
https://ide.codingblocks.com/s/231469 I have attached the code of the input method of your reference. The code you have written is for sorted arrays.
@Rishabh8488,
https://ide.codingblocks.com/s/270504 corrected code.
You had a new line after printing the bstRange as well. Hence the error.