public int searchInRotatedSortedArray(int [] A, int target) {
        int low=0, high=A.length-1;

        while (low<high) {
            int mid=(low+high)/2;
            if (A[mid] < A[high]) {
                if (target>A[mid] && target<=A[high]) low=mid+1;
                else high=mid;
            } else {
                if (target>=A[low] && target<=A[mid]) high=mid;
                else low=mid+1;
            }
        }

        if (A[low]==target) return low;

        return -1;
    }