static int findPivot(int[] a) {
        int lo = 0;
        int hi = a.length - 1;
        while (lo <= hi) {
            while (lo < hi && a[lo] == a[lo + 1]) lo++; // to skip duplicates
            while (hi > lo && a[hi] == a[hi - 1]) hi--; // to skip duplicates
            int mid = lo + (hi - lo) / 2;
            System.out.println(lo + " " + mid + " " + hi);
            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 O(N) in the worst case;
src/problems/medium/SearchinRotatedArray2.java