Never solve the same subproblem twice: memoization, tables and state transitions.
Key ideas
- Never solve the same subproblem twice: keep the answer in a table.
- Define the state ("best up to i"), then the transition: dp[i] comes from a few earlier values.
- Often only the last one or two values matter; you do not need the whole table.
Pattern
dp = [0] * (n + 1)
for i in range(1, n + 1):
dp[i] = max(dp[i - 1], dp[i - 2] + gain(i))Finish these first:Recursion & Divide and ConquerHashing
Lessons
Each lesson explains one idea from zero and ends with a few tasks. Lessons open in order; the explanation can be read at any time.
Boss
05
Longest Increasing
Function
The boss opens when every lesson of the topic is finished. Solve it too and the topic is complete, and the topics after it open.