from typing import List


def buy_sell(arr: List[int]) -> int:
    """
    Solution:
    We traverse the array and keep a record of the index of the highest
    and lowest value.

    The curveball being that if we encounter a new lowest value, we need to
    reset our highest value as well. This is because we must buy before we can
    sell. Therefore, their is a constraint that `index_low <= index_high`.

    Time complexity: O(n). We do a single pass over the array.
    Space complexity: O(1). We are only storing in runtime the indices of low
        and high.
    """
    index_lowest = 0
    index_highest = 0

    for i in range(len(arr)):
        if arr[index_lowest] > arr[i]:
            index_lowest = i
            index_highest = i
        elif arr[index_highest] < arr[i]:
            index_highest = i

    return arr[index_highest] - arr[index_lowest]