1st occurance of number in binary search

instead of doing e=m-1 when arr[mid]==key . cant we first do check :
if (arr[mid-1]==key){
e=m-1;}.

hello @pratik.win no you have to arr[mid]==key only this is because binary search will go and find the element at this position only .

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.