Subject:
Code:
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
If you feel good, please like and follow the message~
Thank you for joining us~