一 思路 其实很简单也没什么说的,上涨就加,没想到还这么快 二 代码 class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ total=0 for i in range(len(prices)-1): k=prices[i+1]-prices[i] if k>0: total+=k return total 三 总结 这个都可以说是暴力法了为什么这么快?