Matrix chain multiplication
Matrix multiplication is associative, but the order changes the cost. solve(start, end) tries every place for the last multiplication — (start..k) × (k+1..end) — paying for both halves plus arr[start-1]·arr[k]·arr[end], and dp remembers each range.
dp holds the ranges already solved.