Class Solution
java.lang.Object
g1001_1100.s1039_minimum_score_triangulation_of_polygon.Solution
1039 - Minimum Score Triangulation of Polygon.<p>Medium</p>
<p>You have a convex <code>n</code>-sided polygon where each vertex has an integer value. You are given an integer array <code>values</code> where <code>values[i]</code> is the value of the <code>i<sup>th</sup></code> vertex (i.e., <strong>clockwise order</strong> ).</p>
<p>You will <strong>triangulate</strong> the polygon into <code>n - 2</code> triangles. For each triangle, the value of that triangle is the product of the values of its vertices, and the total score of the triangulation is the sum of these values over all <code>n - 2</code> triangles in the triangulation.</p>
<p>Return <em>the smallest possible total score that you can achieve with some triangulation of the polygon</em>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/02/25/shape1.jpg" alt="" /></p>
<p><strong>Input:</strong> values = [1,2,3]</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong> The polygon is already triangulated, and the score of the only triangle is 6.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/02/25/shape2.jpg" alt="" /></p>
<p><strong>Input:</strong> values = [3,7,4,5]</p>
<p><strong>Output:</strong> 144</p>
<p><strong>Explanation:</strong> There are two triangulations, with possible scores: 3*7*5 + 4*5*7 = 245, or 3*4*5 + 3*4*7 = 144. The minimum score is 144.</p>
<p><strong>Example 3:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/02/25/shape3.jpg" alt="" /></p>
<p><strong>Input:</strong> values = [1,3,1,4,1,5]</p>
<p><strong>Output:</strong> 13</p>
<p><strong>Explanation:</strong> The minimum score triangulation has score 1*1*3 + 1*1*4 + 1*1*5 + 1*1*1 = 13.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == values.length</code></li>
<li><code>3 <= n <= 50</code></li>
<li><code>1 <= values[i] <= 100</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minScoreTriangulation
public int minScoreTriangulation(int[] values)
-