【100Days of 100 line Code】7 day

这两天可能是太费脑子了,今天有点吃不消了。。

以后尽量调整一下作息,这样以后才能有身体资本被资本家剥削啊233333.。。

今天只做了一道题。

还是题做少了,和之前的一样,卡在最后一个点没有完成。

LeetCode #121 买卖股票的最佳时间

目前只想到了暴力法

class Solution(object):
    def maxProfit(self, prices):
        """
        :type prices: List[int]
        :rtype: int
        """
        if prices == [] :
            return 0
        new_list = [0]
        for i in range(len(prices)-1):
            max = 0
            print (i)
            for j in range(i+1,len(prices)):
                if max > prices[i] - prices[j] :
                    new_list.append(prices[j] - prices[i])
        new_list.sort()
        return new_list[-1]
原文地址:https://www.cnblogs.com/mygzhh/p/9321077.html