任务描述
思路
- = = 没啥特别的思路
实现代码
class Solution:
def maxProfit(self, prices: List[int]) -> int:
if not prices:
return 0
price = prices[0]
maxpro = 0
for i in range(1,len(prices)):
if prices[i]<price:
price = prices[i]
else:
pro = prices[i]-price
maxpro += pro
price = prices[i]
return maxpro