def greatest_profit(array: list): 
	"""given array return the maximum profit from one buy and sell
	the following algorithm does so in O(N) time
	"""	
	minimum_price = array[0]
	maximum_price = array[0]
	greatest_profit = 0

	for price in array:
		if price < minimum_price:
			minimum_price = price
			maximum_price = price
		
		if price > maximum_price:
			maximum_price = price

		if maximum_price - minimum_price  > greatest_profit:
			greatest_profit = maximum_price - minimum_price 
	return greatest_profit