Dynamic Programming 1¶
what to do when asking a DP question¶
- base case
- induction rule: DP[i] physical meaning
find global min/max¶
- recusion: DFS -> permute all possible outcomes -> optimal
- BFS - heap
- Greedy - need proof
- DP
Q0: largest sum of a subarray¶
{1, 2, 4, -1, -2, 10, 1} => {1, 2, 4, -1, -2, 10} with max sum of 14
Q1: maximal product: cutting rope¶
Given a rope, cut the rope so that the product of total length is max
Last update:
January 9, 2021