Run errors : Delete Nodes from BST

I am facing run errors in my code.
My remove function is working fine.
Please have a look at " constructBST " function.
I have highlighted it in the code.

your remove function is not working for the cases when you want to remove the root node in such a case your parent will be null and you try to access parent.left or parent.right then it will show null pointer exception.

run your code for this test case
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

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.