Cheapest Triangulation of a Convex Geofence Polygon
Last updated: November 29, 2026
Quick Overview
A convex geofence polygon has labeled vertices in order. Each triangle in a triangulation costs the product of its three vertex labels. Return the minimum total cost of triangulating the polygon.
Meta
November 29, 20260
0
0 solved
A convex geofence polygon has labeled vertices in order. Each triangle in a triangulation costs the product of its three vertex labels. Return the minimum total cost of triangulating the polygon.
A less common interval DP question that appears in Meta onsites with a maps or location services framing. The interviewer wants to see you identify that edge (i, j) must belong to exactly one triangle whose third vertex k splits the polygon into two independent parts.
What the Interviewer Expects
- Recognize the edge (0, n-1) sits in exactly one triangle
- Define dp[i][j] over the sub-polygon from vertex i to j
- Try every apex k between i and j
- Fill by increasing span
- State O(n^3) time
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How many triangulations does a convex n-gon have?
- How does this relate to matrix chain multiplication?
- How would you output the chosen triangles?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input is a list w of positive integers for vertices 0..n-1 of a convex polygon, with 3 <= n <= 50. A triangulation splits the polygon into n - 2 triangles with non-crossing diagonals. Return t...
High-Level Design
Look at the side from vertex i to vertex j of the sub-polygon i, i+1, ..., j. In any triangulation, that side belongs to exactly one triangle (i, k, j) with i < k < j. That triangle cuts the...