📄️ Pattern 5: State Machine DP Problems
The Mode Transition Pattern: At each position i, track different states/modes. Transitions between states have costs/constraints. State represents "what mode/condition am I in?"
📄️ 💹 Best Time to Buy and Sell Stock II
Problem: You are given an integer array prices where prices[i] is the price of a stock on day i. You can buy and sell the stock unlimited times, but you can only hold at most one share at a time. Return the maximum profit.
📄️ 📊 Best Time to Buy and Sell Stock III
Problem You cannot engage in multiple transactions simultaneously (must sell before buying again).
📄️ 📈 Best Time to Buy and Sell Stock IV
Problem You cannot engage in multiple transactions simultaneously (must sell before buying again).