i tried to solve it but i approached till half solved part either left or right but don’t know how to solve together with binary search
Problem with approach
it is not working for 2 3 4 5 1 and 1 2 3 4 5
no, just tell me that is it work for 1 2 3 4 5 or not?
in case of 1 2 3 4 5 it is infinite loop
hello @ashish_arora369
handle it seprately
if a[0] < a[n-1] it means complete array is sorted in that case u can say pivot is n-1.
for other cases follow what himanshu said
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.