class Solution:

    def maxProfit(self, prices: List[int]) ->int:
        if not prices:
            return 0
        min_val = prices[0]
        max_val = 0
        for i in range(len(prices)):
            if prices[i] < min_val:
                min_val = prices[i]
            else:
                max_val = max(max_val, prices[i] - min_val)
        return max_val

f61f62ec35e39f5cf31a12300d1d0a8b8fbd96aa
<mask token>

class Solution:
    <mask token>

class Solution:

    def maxProfit(self, prices: List[int]) ->int:
        if not prices:
            return 0
        min_val = prices[0]
        max_val = 0
        for i in range(len(prices)):
            if prices[i] < min_val:
                min_val = prices[i]
            else:
                max_val = max(max_val, prices[i] - min_val)
        return max_val
