Only one element is getting deleted!?


There was a minor mistake in the build function. Check it now, it is deleting all the required nodes.
Note: to get the result as the desired output in this question, while deleting you need to replace the root node with its immediate predecessor. Here you are replacing with its immediate successors. So make changes from line number 61 to 66 and try to submit.

output should be -> 4 7 6 8 but it is coming -> 6 4 7 8

No fine, it is given wrong on hacker blocks

From line 61 to 66 replace all left with right and right with left as i said before and then check