Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 1039 Minimum Score Triangulation of Polygon - Problem Statement

Polygon DP

Triangulate a convex polygon to find the lowest sum of triangle scores. Score of triangle = product of vertices. dp[i][j]dp[i][j] = min cost to triangulate the polygon formed by vertices ii to jj.

Transition: pick a vertex kk between ii and jj to form triangle (i,k,j)(i, k, j). Cost = v[i]v[k]v[j]+dp[i][k]+dp[k][j]v[i] \cdot v[k] \cdot v[j] + dp[i][k] + dp[k][j]. This is Matrix Chain in disguise! The "matrices" are edges, and triangles are the "multiplications".