class Solution:
def maxProfit(self, prices: List[int]) -> int:
#找到一个最大值,一个最小值,分别为利润和买入价格
if prices==[]:
return 0
max_profit,min_price=0,float('inf')
for price in prices:
min_price=min(min_price,price)
max_profit=max(max_profit,price-min_price)
return max_profit