Description
Given the vertices of a simple polygon listed in order (clockwise or counter-clockwise) as integer (x, y) pairs, return twice its area as an integer. Use the shoelace formula.
Examples
Input:
points = [[0,0],[4,0],[4,3]]Output:
12Explanation:
Right triangle area 6, doubled 12.
Input:
points = [[0,0],[2,0],[2,2],[0,2]]Output:
8Explanation:
Unit square scaled, area 4, doubled 8.
Input:
points = [[1,1],[5,1],[5,4],[1,4]]Output:
24Explanation:
Rectangle 4x3 area 12, doubled 24.
Constraints
- •
3 ≤ vertices ≤ 100 - •
-10⁶ ≤ coords ≤ 10⁶