why there is condition with leftans and not with rightans, in general when do this type of question we do the same for both left and right sides so why not here, i know code is working but how ??
if(leftans->left!=NULL)
return leftans;
return rightans;