1D DP

Apply DP to linear problems. House Robber, Boredom, and Consecutive Subsequence. Each problem uses a 1D state array.

41 lessons
194 min
Codeforces: 1100-1800LeetCode: 1400-1800

Lessons

1. Intro

One state variable

4m

2. From Memoization to Problems

The transition

3m

3. DP Pattern and Importance

The four-step blueprint

4m

4. LeetCode 198 House Robber - Problem Statement

The classic problem

4m1 problems

5. LeetCode 198 House Robber - Why Greedy Fails

Why odd/even sums fail

4m

6. LeetCode 198 House Robber - Defining the DP

Setting up the state

4m

7. LeetCode 198 House Robber - Transition

The take-or-skip choice

5m

8. LeetCode 198 House Robber - Base Cases

Starting conditions

4m

9. LeetCode 198 House Robber - Final Answer

Reading the answer

4m

10. LeetCode 198 House Robber - Implementation

Putting it together

7m1 problems

11. Quiz: House Robber State

Testing DP state design

3m1 problems

12. Lessons from House Robber

summary

5m

13. Codeforces 455A Boredom - Problem Statement

A similar structure

4m1 problems

14. Codeforces 455A Boredom - Defining the DP

First 1D DP problem

8m

15. Codeforces 455A Boredom - Transition

Take or skip each value

8m

16. Codeforces 455A Boredom - Base Cases

Starting conditions

4m

17. Codeforces 455A Boredom - Final Answer

Reading the answer

8m

18. Codeforces 455A Boredom - Implementation

Complete solution

6m1 problems

19. Quiz: Boredom Reduction

Testing problem reduction

3m1 problems

20. Codeforces 977F Consecutive Subsequence - Problem Statement

Large values, same pattern

5m1 problems

21. Codeforces 977F Consecutive Subsequence - State Definition - 1

Learn how to define the DP state for finding the longest consecutive subsequence.

5m

22. Codeforces 977F Consecutive Subsequence - State Definition - 2

Extra requirements for state definition.

4m

23. Codeforces 977F Consecutive Subsequence - Transition

Learn the transition formula: extend subsequences by linking consecutive values.

4m

24. Codeforces 977F Consecutive Subsequence - Base Cases

Learn how to initialize the DP values before processing the array elements.

4m

25. Codeforces 977F Consecutive Subsequence - Final Answer and Reconstruction

Learn how to find the answer and rebuild the subsequence

7m

26. Codeforces 977F Consecutive Subsequence - Implementation

Putting it all together

7m1 problems

27. Quiz: Consecutive Subsequence

Testing LIS variant

3m1 problems

28. Vocabulary - State Compression

Reducing DP dimensions

4m

29. Lessons from Boredom and Consecutive Subsequence

Patterns from both problems

5m

30. Pattern - Adjacent Blocking

The common structure

4m

31. Challenge: Trace Boredom

Manual DP exercise

4m

32. Quiz: 1D DP Patterns

Test your understanding

3m1 problems

33. Codeforces 1741E Sending a Sequence - Problem Statement

Understand the block cutting problem where each block has a length marker

5m1 problems

34. Codeforces 1741E Sending a Sequence - From Intuition to Prefix States

From intuition to states

5m

35. Codeforces 1741E Sending a Sequence - Defining the State and Base Case

Learn how to define the DP state using prefix arrays

4m

36. Codeforces 1741E Sending a Sequence - Determining the Final Answer

Learn how to extract the final answer from the DP state

4m

37. Codeforces 1741E Sending a Sequence - Transition Case 1

Right End Block

5m

38. Codeforces 1741E Sending a Sequence - Transition Case 2

Left End Block

7m1 problems

39. Practice - Maximum Points

Apply the pattern

6m

40. What's Next

Preview of 2D DP

4m

41. Section Recap

What you learned and what comes next

3m

Practice Problems

1.
BoredomCodeforceseasy

Classic take/skip pattern where you decide whether to take all instances of a number or skip it

2.

Extends Frog 1 with variable jump length K - teaches handling multiple transitions per state.

3.
Color StripeCodeforcesmedium

DP with greedy construction, teaches state optimization on linear arrays

4.
Cut RibbonCodeforcesmedium

Classic coin-change variant teaching maximization in 1D DP

5.
WoodcuttersCodeforcesmedium

Greedy-DP hybrid teaching when left/right decisions create 1D DP

6.
Delete and EarnLeetCodemedium

Direct application of house robber pattern with frequency counting twist

7.

Index-based recursion and decision making converge in one foundational DP problem

8.
Consecutive SubsequenceCodeforcesmedium

Finds the longest consecutive-value subsequence with DP and reconstructs it.

9.

1D DP on character arrays with constraint-based transitions

10.

Linear DP after sorting, teaches preprocessing for state optimization

Ready to start learning?

Access all 41 lessons with interactive content and progress tracking.