Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Trapezoids I

med
30 min
Try to solve the Count Number of Trapezoids I problem.

Statement

You are given a 2extD2 ext{D} integer array points where points[i] =[xi,yi]= [x_i, y_i] represents the coordinates of a point on the XYXY plane.

Return the total number of distinct horizontal trapezoids that can be formed using 44 points from points.

A horizontal trapezoid is a quadrilateral with at least one pair of parallel horizontal sides (parallel to the XX axis). That is, its 44 vertices must consist of 22 distinct points sharing a common yy coordinate and 22 distinct points sharing a different common yy coordinate.

Constraints:

  • 4≤4 \leq points.length ≤105\leq 10^5

  • −108≤xi,yi≤108-10^8 \leq x_i, y_i \leq 10^8

  • All points are pairwise distinct.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Trapezoids I

med
30 min
Try to solve the Count Number of Trapezoids I problem.

Statement

You are given a 2extD2 ext{D} integer array points where points[i] =[xi,yi]= [x_i, y_i] represents the coordinates of a point on the XYXY plane.

Return the total number of distinct horizontal trapezoids that can be formed using 44 points from points.

A horizontal trapezoid is a quadrilateral with at least one pair of parallel horizontal sides (parallel to the XX axis). That is, its 44 vertices must consist of 22 distinct points sharing a common yy coordinate and 22 distinct points sharing a different common yy coordinate.

Constraints:

  • 4≤4 \leq points.length ≤105\leq 10^5

  • −108≤xi,yi≤108-10^8 \leq x_i, y_i \leq 10^8

  • All points are pairwise distinct.