0%
1 2 3 4 5 6 7 8 9 10 11
| class Solution: def maxProfit(self, prices: List[int]) -> int: d = [[0,0] for _ in range(len(prices))] d[0][0] = -prices[0] for i in range(1,len(prices)): d[i][0] = max(d[i-1][0],d[i-1][1]-prices[i]) d[i][1] = max(d[i-1][1],d[i-1][0]+prices[i]) return max(d[len(prices)-1][1],d[len(prices)-1][0])
|