121

class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        if len(prices) == 0: return 0
        maxPro, minPrice = 0, prices[0]
        for i in range(1,len(prices)):
            if prices[i] <= minPrice: minPrice = prices[i]
            else: maxPro = max(maxPro, prices[i]-minPrice)
        return maxPro


上一篇:python-leetcode9回文数


下一篇:小白刷题——回文数