题目:

题解:
func maxProfit(prices []int) int {
if len(prices) == 0 {
return 0
}
n := len(prices)
f0, f1, f2 := -prices[0], 0, 0
for i := 1; i < n; i++ {
newf0 := max(f0, f2 - prices[i])
newf1 := f0 + prices[i]
newf2 := max(f1, f2)
f0, f1, f2 = newf0, newf1, newf2
}
return max(f1, f2)
}
func max(x, y int) int {
if x > y {
return x
}
return y
}









![[Bugku] web-CTF-POST](https://i-blog.csdnimg.cn/direct/ba58cbb43aeb482e81cfede6bae8aba9.png)
![[240802] 有关 Homebrew 的安全审核 | Running C++ anywhere like a script](https://i-blog.csdnimg.cn/direct/a162c7aaf4b4496eac63056de50c5857.png#pic_center)







