> For the complete documentation index, see [llms.txt](https://celia-qian.gitbook.io/leetcode-notebook-2020-2021/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://celia-qian.gitbook.io/leetcode-notebook-2020-2021/tan-xin-fa/untitled/exercises.md).

# Exercises

## Best Time to Buy and Sell Stock with Transaction Fee

[原题链接](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/)

medium

解法：

```cpp
class Solution {
public:
    int maxProfit(vector<int>& prices, int fee) {
        int maxprofit=0, hold=-prices[0];
        for(int i=1; i<prices.size(); i++){
            maxprofit=max(maxprofit,hold+prices[i]-fee);
            hold=max(hold,maxprofit-prices[i]);
        }
        return maxprofit;
    }
};
```

## Best Time to Buy and Sell Stock with Cooldown

[原题链接](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/)

medium

解法

```cpp
```
