您的位置:首页 > 其它

Leetcode 121 Best Time to Buy and Sell Stock

2015-07-04 17:10 309 查看
class Solution:
# @param {integer[]} prices
# @return {integer}
def maxProfit(self, prices):
if len(prices) <= 1: return 0
low = prices[0]; mostProfit = 0
for i in range(1, len(prices)):
if prices[i] < low: low = prices[i]
mostProfit = max(mostProfit, prices[i] - low)
return mostProfit
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: