Skip to main content

🟢 剑指 Offer 63. 股票的最大利润

LeetCode 提示

题目难度 简单

原题链接 🔗 leetcode

题解 1_不用动态规划.py#

class Solution:    def maxProfit(self, prices: List[int]) -> int:        if not prices:            return 0        maxx = 0        low = prices[0]        for idx in range(1, len(prices)):            maxx = max(maxx, prices[idx]-low)            low = min(low, prices[idx])        return maxx