Unable to get the mistake

I am able to delete the nodes rightly but am not sure of how to build a bst without sorting the array

try this

I figured out the solution, though still getting RTE for some test cases, could you help figure out where may I make changes to tackle that. Thank You!

Hey @neetigya
try for this input
1
18
172 468 963 94 951 803 683 630 198 672 327 216 451 738 798 251 558 159
11
683 159 327 94 451 738 798 172 468 963 738