##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Apply DP to linear problems. House Robber, Boredom, and Consecutive Subsequence. Each problem uses a 1D state array.
One state variable
The transition
The four-step blueprint
The classic problem
Why odd/even sums fail
Setting up the state
The take-or-skip choice
Starting conditions
Reading the answer
Putting it together
Testing DP state design
summary
A similar structure
First 1D DP problem
Take or skip each value
Starting conditions
Reading the answer
Complete solution
Testing problem reduction
Large values, same pattern
Learn how to define the DP state for finding the longest consecutive subsequence.
Extra requirements for state definition.
Learn the transition formula: extend subsequences by linking consecutive values.
Learn how to initialize the DP values before processing the array elements.
Learn how to find the answer and rebuild the subsequence
Putting it all together
Testing LIS variant
Reducing DP dimensions
Patterns from both problems
The common structure
Manual DP exercise
Test your understanding
Understand the block cutting problem where each block has a length marker
From intuition to states
Learn how to define the DP state using prefix arrays
Learn how to extract the final answer from the DP state
Right End Block
Left End Block
Apply the pattern
Preview of 2D DP
What you learned and what comes next