import sys class Solution(object):     def maxProfit(self, prices):         """         :type prices: List[int]         :rtype: int         """         if not prices:return 0           mp = [[[0,0]for _ in range(3)]for _ in range(len(prices))]         mp[0][0][0], mp[0][0][1] = 0,-prices[0]         mp[0][1][0], mp[0][1][1] = -sys.maxsize,-sys.maxsize         mp[0][2][0], mp[0][2][1] = -sys.maxsize,-sys.maxsize           for i in range(1,len(prices)):             mp[i][0][0] = mp[i-1][0][0]             mp[i][0][1] = max(mp[i-1][0][1],mp[i-1][0][0]-prices[i])               mp[i][1][0] = max(mp[i - 1][1][0], mp[i - 1][0][1] + prices[i])             mp[i][1][1] = max(mp[i - 1][1][1], mp[i - 1][1][0] - prices[i])               mp[i][2][0] = max(mp[i - 1][2][0], mp[i - 1][1][1] + prices[i])           end = len(prices) - 1         print( max(mp[end][0][0],mp[end][1][0],mp[end][2][0])) 这个通过率100
点赞 1

相关推荐

11-04 10:30
已编辑
门头沟学院 研发工程师
开心小狗🐶:“直接说答案”
点赞 评论 收藏
分享
程序员花海_:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务