For some test cases, the brute force way won’t pass. Only use the modified binary search will pass all the test cases. For example:
searchRotatedArray([5,5,5,5,5,5,5],0,6,)5
The expected output is 3 which does not really make sense because the first index matches the target is 0. If the requirement is asking for the last index mataches the target, the index should be 5. None gives 3.
Course: https://www.educative.io/collection/10370001/5347133077061632
Lesson: https://www.educative.io/collection/page/10370001/5347133077061632/5094816851427328