题解 | #买卖股票的最好时机 ii#

买卖股票的最好时机 ii

http://www.nowcoder.com/practice/572903b1edbd4a33b2716f7649b4ffd4

class Solution:
def maxProfit(self , prices ):
# write code here
maxpro = 0
n = len(prices)
for i in range(n-1):
if prices[i+1]>prices[i]:
maxpro+=prices[i+1]-prices[i]
return maxpro

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务