(self, prices: List[int])
| 1 | class Solution: |
| 2 | def maxProfit(self, prices: List[int]) -> int: |
| 3 | maxProfit = 0 |
| 4 | currentMax = 0 |
| 5 | |
| 6 | for i in reversed(prices): |
| 7 | currentMax = max(currentMax, i) |
| 8 | profit = currentMax - i |
| 9 | maxProfit = max(profit, maxProfit) |
| 10 | return maxProfit |