Doubt in code in line where ans is there

If instead of doing max(ans,mid) if we did ans =mid then will it work or not like done in previous questions

@kunal81198
Please share the code