As the array is sorted but rotated,
If we have a loop to iterate over whole array in such a way that whenever the next element is smaller than prev it is the break point about which array was rotated,So we put index there and again rotate to make it a unrotated sorted array and then just find the key by binary or iterating search
Alternative Approach ,Is it right?
I am not so sure about this approach. But you can still try to code and submit it. See if it gets accepted.
Else the suggested approach is to first search for the pivot element (about which the array is rotated), and then use binary search in both the parts of the array obtained.
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.