问题描述:股票买进卖出问题
代码示例:动态规划
class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
length = len(prices)
if length == 0 : return 0
buy_price = prices[0]
max_value = 0
for i in range(1,length):
if prices[i] < buy_price:
buy_price = prices[i]
max_value = max(max_value, prices[i]-buy_price)
return max_value