Convex Polygon
From LeetCode. Convexity check. Solve the geometry problem "Convex Polygon".
Examples
Input: [1,2,3]
Output: 0
Input: [2,3,4]
Output: 0
Hints
Core concept: cross product of consecutive edge vectors tells turn direction. Convex polygon = all turns same direction (all left or all right).
For each vertex i, compute cross = (p[i+1]-p[i]) × (p[i+2]-p[i+1]) = x1*y2 - x2*y1. Skip zero cross (collinear). If any non-zero cross has opposite sign from first non-zero cross, return false.
Wrap around with modulo n for ring closure. Zero cross allowed — only sign changes matter. Simple polygon guarantee means no self-intersection to worry about.
Convex Polygon
**From LeetCode.** Convexity check. Solve the geometry problem "Convex Polygon".