class Solution:
    def get_max_profit(self, prices):
        if not prices:
            return 0
        
        max_profit, max_here = 0, 0
        for i in range(1, len(prices)):
            max_here = max(max_here + prices[i] - prices[i - 1], 0)
            max_profit = max(max_profit, max_here)
        return max_profit

def get_max_profit2(self, prices):
    if not prices:
        return 0
    
    buy, sell = float('-inf'), 0

    for price in prices:
        buy = max(buy, - price)
        sell = max(sell, price + buy)
    
    return sell