题目:
代码:
class Solution:
def maxProfit(self, prices: List[int]) -> int:
if not prices:
return 0
profit = 0
buy_stock = prices[0]
for i in range(len(prices)):
if buy_stock > prices[i]:
buy_stock = prices[i]
profit = max(prices[i] - buy_stock, profit)
return profit
如果觉得不错,就点赞关注留言~
谢谢各位捧场~