# 遍历列表，记录价格最小值，保存最大差值
class Solution(object):
    def maxProfit(self, prices):
        min_p, max_p = 99999, 0
        for i in prices:
            min_p = min(min_p, i)
            max_p = max(max_p, i-min_p)
        return max_p
04d827dfc6af70084ba01189c5e0867ebef952cf
<mask token>

class Solution(object):
    <mask token>

class Solution(object):

    def maxProfit(self, prices):
        min_p, max_p = 99999, 0
        for i in prices:
            min_p = min(min_p, i)
            max_p = max(max_p, i - min_p)
        return max_p

# 遍历列表，记录价格最小值，保存最大差值
class Solution(object):
    def maxProfit(self, prices):
        min_p, max_p = 99999, 0
        for i in prices:
            min_p = min(min_p, i)
            max_p = max(max_p, i-min_p)
        return max_p