Delete Tree Node

I am getting only one test case passed. Please tell me why am I not getting all correct.
Here is my code

Sure!! give me some time i will check your code

Hi aman , your code for the case when the node to be deleted has two child is not correct
what you have to do for that case is to find the maximum value node in left subtree OR minimum value node in the right subtree and replace that node with the node to be deleted and call delete function on left subtree or right subtree depending upon from which subtree you replace the node value

what you did is you replaced the node value with the smallest value in left subtree instead of right subtree that’s why you got WA.
I have made changes in your code : https://ide.codingblocks.com/s/181176

In case of any doubt feel free to ask :slight_smile:

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.