def find_pivot(input_arr, min_idx, max_idx):
    """
    Find the the pivor index of an rotated array
    
    Time complexity: O(1og2(n))
    Space Complexity: O(1)

    Args:
       input_array(array): rotated array
    Returns:
       pivot_idx(int)
    """
    
    mid = (min_idx + max_idx) // 2
    
    # if  mid element is higher than the next one, we found an pivot
    if mid < max_idx and input_arr[mid] > input_arr[mid + 1]: 
        return mid 
    # if  mid-1 element is higher than the next one (mid element), we found an pivot
    if mid > min_idx and input_arr[mid] < input_arr[mid - 1]: 
        return (mid-1) 
    
    # if the first element is higher than the current (mid) element,
    # call recrusion for the lower interval
    if input_arr[min_idx] >= input_arr[mid]: 
        return find_pivot(input_arr, min_idx, mid-1)
    # else if the first element is lower than the current (mid) element,
    # call recrusion for the higher interval
    else:
        return find_pivot(input_arr, mid + 1, max_idx)