leetcod 121

题目

在这里插入图片描述

class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        n=len(prices)
        res=0
        for i in range(n):
            for j in range(i,n):
                res=max(res,prices[j]-prices[i])
        return res

发布了111 篇原创文章 · 获赞 1 · 访问量 2264

猜你喜欢

转载自blog.csdn.net/weixin_45568353/article/details/104529873
今日推荐