> For the complete documentation index, see [llms.txt](https://yyloumike.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yyloumike.gitbook.io/leetcode/dp/buy-and-sell-stock.md).

# Buy and Sell Stock (6 Qs)

Series of problems related to "Best Time to Buy and Sell Stock"

{% hint style="info" %}
We could solve these problems using the same concept, **Final State Machine**. Only two states are required for us to come up with the solution:

* **Hold State** - The profit when we hold the stock. It could indicate that **we already hold the stock and don't sell it** or **just buy a stock**.<br>
* **No-hold State** - The profit when we don't hold the stock. It could indicate that **we haven't bought any stocks** or **just sell a stock**.

**Note** that **we could decide not to perform any actions** (either buy or sell) in a certain day if we cannot gain more profits.
{% endhint %}

**Related problems (follow the order to solve each problem):**

* [0122. Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/)
* [0714. Best Time to Buy and Sell Stock with Transaction Fee](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee)
* [0121. Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)
* [0309. Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/)
* [0123. Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/)
* [0188. Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/) ***(Same solution as 0123)***
