Skip to main content
LeetCode 469, Medium. Topics: Geometry, Array, Math, Polygon. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 12 parametrized pytest cases, and a playground notebook:

Problem

You are given an array of points on the X-Y plane points where points[i] = [x_i, y_i]. The points form a polygon when joined sequentially. Return true if this polygon is convex and false otherwise. You may assume the polygon formed by given points is always a simple polygon. In other words, we ensure that exactly two edges intersect at each vertex and that edges otherwise don’t intersect each other.

Examples

Example 1
Example 2

Constraints

  • 3 <= points.length <= 10^4
  • points[i].length == 2
  • -10^4 <= x_i, y_i <= 10^4
  • All the given points are unique.

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Last modified on September 7, 2026