static int findPivot(int[] a) {
        int lo = 0;
        int hi = a.length - 1;
        while (lo <= hi) {
            int mid = lo + (hi - lo) / 2;
            if (mid == lo || mid == hi) {
                if (a[lo] < a[hi]) return lo;
                else return hi;
            }
            if (a[mid] > a[hi]) lo = mid;
            else if (a[mid] < a[hi]) hi = mid;
            else return mid;
        }
        return lo;
    }
Solution is easy, we first find rotated pivot index and binary search both sides of pivot.
Time complexity is Log(N);
This does not solve when there is duplicates in the array. please look at SearchinRotatedSortedArray.java
for duplicate support
src/problems/medium/SearchinRotatedSortedArray.java