def reverse(A, b, e):
    """Completely flip the given array/subarray.

    Args:
        A (array): the array to flip.
        b (int): the index of the beginning of the array/subarray
                 to flip
        e (int): the index of the end of the array/subarray to flip

    Returns:
        array: the refersed array
    """
    i = b
    j = e

    while i != j:
        A[i], A[j] = A[j], A[i]

        if (i + 1 == j):
            break

        i += 1
        j -= 1

    return A