Minimum Score Triangulation of Polygon
GivenN, consider a convexN-sided polygon with vertices labelledA[0], A[i], ..., A[N-1] in clockwise order.
Suppose you triangulate the polygon intoN-2triangles. For each triangle, the value of that triangle is theproduct of the labels of the vertices, and the_total score_of the triangulation is the sum of these values over allN-2triangles in the triangulation.
Return the smallest possible total score that you can achieve with some triangulation of the polygon.
Example 1:
Input:
[1,2,3]
Output:
6
Explanation:
The polygon is already triangulated, and the score of the only triangle is 6.Example 2:

Example 3:
Note:
分析
注意初始化可以为最大,前三个点设为0
top down dfs
bottom up DP
遍历长度d>[2-n] ,left [0- n-d]
从小长度到大长度。 其他遍历法要倒序
Last updated
Was this helpful?