Doubt in the code

my code is giving tle please check

Hey @Adhyayan
just a change
if (arr[mid] == key) {
ans = mid;
return ans; // mera changes
}
correct code