题目:

题解:
class Solution:
def maxProfit(self, prices: List[int]) -> int:
if not prices:
return 0
n = len(prices)
f0, f1, f2 = -prices[0], 0, 0
for i in range(1, n):
newf0 = max(f0, f2 - prices[i])
newf1 = f0 + prices[i]
newf2 = max(f1, f2)
f0, f1, f2 = newf0, newf1, newf2
return max(f1, f2)
![【笔记】《冲击弹性波理论与应用》[2-2] 振动信号分析](https://i-blog.csdnimg.cn/direct/e669890d76914764a5b7b1285e3de3db.png)


















