DP on Intervals pattern
The state dp[left, right] answers one interval. Try a middle point, combine both smaller intervals, and keep the best result.
Difficulty: Hard · Approach: Save each smaller answer once
This is a public lesson preview. Sign in with a Lifetime Pass to open the protected animation, solution, and code.