基本题意题解动态规划方法121. Best Time to Buy and Sell Stock 基本题意 题解 动态规划方法class Solution: def maxProfit(self, prices: List[int]) -> int: pre_min = prices[0] ans = 0 for price in prices: ans = max(ans, price-pre_min) pre_min = min(pre_min, price) return ans