Delete node from bst

my test case is correct , but my submission is getting all the wrong answer , can you tell me where i am wrong,
here is my code

@diwakargour121
You have constructed your tree after sorting the array. The resultant tree will be a balanced BST. It is not specified in the problem that your tree must be balanced BST. You were simply required to insert each of the elements into the tree one by one after comparing them. Sorting and then inserting the elements into the tree will give you a different tree and hence incorrect order.

i have made the changes , some test cases are coming wrong , please help me with it

@diwakargour121
Please share your updated code.

this is the code ,sir

@diwakargour121
Try this testcase -

Input :
1
7
5 3 2 4 7 6 8
4
2 3 5 6

Expected Output :
7 4 8

Your Output :
8 4 7

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.