← DSADSA 5.9
State Machine DP
Not started yet — 6 problems queued, the entire buy/sell-stock family in one sub-pattern.
Model the problem as explicit states (holding stock / not holding / in cooldown, for example) with transitions each step; dp tracks the best value per state.
Sub-patterns
- A — Buy/Sell Stock Family. Holding vs. not holding, with cooldown and transaction-fee variants.
- B — General Finite-State Transition DP. The same explicit-states-and-transitions idea applied beyond stock problems.
Practice set (6)
- Easy — Best Time to Buy and Sell Stock
- Medium — Best Time to Buy and Sell Stock II, Best Time to Buy and Sell Stock with Cooldown, Best Time to Buy and Sell Stock with Transaction Fee
- Hard — Best Time to Buy and Sell Stock III, Best Time to Buy and Sell Stock IV
Notes from readers
Comments — via GitHub