Kindly tell me the error in my code

I am not getting the error in building the tree and getting pre order

What is going wrong with the solution ?
Are some test cases not passing ?
Please reply with the link to the problem statement.

Test cases are not passing
problem stat is given near bulb sign
@prashuk156

Do not sort the elements to make the BST(Binary Search Tree) because that will cause a difference between your output and the output against which your output will be matched.
To create a BST, make the first element as the root node of the tree and then add every other subsequent element to this tree while maintaining the property of the BST.
Now do a pre order traversal and print the nodes with value between k1 and k2 (both included).

If you would like to know how to create a BST in this way, go to this link

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.