买卖股票的最佳时机
https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/ (opens new window)
class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
profit = 0
minprice = prices[0]
for i in range(1, len(prices)):
profit = max(profit, prices[i] - minprice)
minprice = min(minprice, prices[i])
return profit