Code not getting accepted for "Delete Nodes from BST"

I have gone through my code several times, it passes the example test case, but I am unable to detect the reason why it shows an error upon submission.

Kindly assist and suggest changes if need be.

Regards,
Ajay Bhat.

@ajay_bhat hi bro lemme review it!

@ajay_bhat bro basically here your logic of sorting and building the tree won’t work because the question does not want you to sort the array, it just wants that you insert the nodes in order they are coming according to whether they should be placed in left or right subtree based on data value.

Here I am attaching the code for your reference about another way of tree construction.

Just refer the fully functional code below -

And try to run both the codes for input say -
3 1 2, you will get the problem.

Yes, thank you very much. I shall do the necessary changes and see.