> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/0714_best_time_to_buy_and_sell_stock_with_transaction_fee/slt.md).

# 思路1 dp

has\[i]表示第i天手上有股票，not\[i]表示第i天手上没有股票，递归方程：

* has\[i] = max(has\[i-1], not\[i-1] - prices\[i])       （第二项表示在第i天买入股票）
* not\[i] = max(not\[i-1], has\[i-1] + prices\[i] - fee)  （第二项表示在第i天将股票卖出，需扣除手续费）
