You're a buyer/seller and your buisness is at stake... You ___need___ to make profit... Or at least, you need to lose the least amount of money!  
Knowing a list of prices for buy/sell operations, you need to pick two of them. Buy/sell market is evolving across time and the list represent this evolution. First, you need to buy one item, then sell it later. Find the best profit you can do.

### Example:

Given an array of prices `[3, 10, 8, 4]`, the best profit you could make would be `7` because you buy at `3` first, then sell at `10`.

# Input:

A list of prices (integers), of length 2 or more.

# Output:

The result of the best buy/sell operation, as an integer.



### Note:
Be aware you'll face lists with several thousands of elements, so think about performance.

Difficulty: introductory

Starter code:

def max_profit(prices):
	

Solutions:
def max_profit(prices):
    m = best = float('-inf')
    for v in reversed(prices):
        m, best = max(m, best-v), max(best,v)
    return m

def max_profit(prices):
    out = prices[1] - prices[0]
    min_price = prices[0]
    
    for i in prices[1:]:
        if i - min_price > out:
            out = i - min_price
        if i < min_price:
            min_price = i
    return out

def max_profit(prices):
    save, best = float('inf'), float('-inf')
    for p in prices:
        best = max(best, p-save)
        save = min(save, p)
    return best

def max_profit(prices):
    mini, best = prices[0], -prices[0]
    for price in prices[1:]:
        best = max(best, price - mini)
        mini = min(mini, price)
    return best

from itertools import islice

def max_profit(prices):
    result = prices[1] - prices[0]
    m = prices[0]
    for x in islice(prices, 1, None):
        result = max(x-m, result)
        m = min(x, m)
    return result

import numpy as np

def max_profit(prices):
    p = np.array(prices)
    return np.array([p[i+1:].max() - prices[i] for i in range(len(prices)-1)]).max()

def max_profit(prices):
    low = prices[0]
    profit = prices[1] - low
    for i in range(1, len(prices)):
        profit = max(profit, prices[i] - low)
        low = min(low, prices[i])
    return profit

def max_profit(arr): 
    max_diff = arr[1] - arr[0] 
    min_element = arr[0] 
      
    for i in range(1, len(arr)): 
        if (arr[i] - min_element > max_diff): 
            max_diff = arr[i] - min_element 
      
        if (arr[i] < min_element): 
            min_element = arr[i] 
    return max_diff 


import numpy as np
def max_profit(prices):
    p = np.array(prices)
    pr = np.array([])
    for i in range(len(prices)-1):
        pr = np.append(pr, [p[i+1:].max() - prices[i]])
    return pr.max()